Question

So here is my problem, i have a CtrlList, and I want to insert items via PostMessage (asyncron) therefore the message LVM_INSERT_MESSAGE, is going to be processed when it is his turn, but the problem is i need to allocate memory for LVITEM, so that i don't loose it before i insert the item. But after i loose the pointer to the allocated item after exiting the function. And since insert item creates another item, i find it hard to deallocate the memory i allocate for LVITEM.

My solution was since LVM_INSERT_MESSAGE sends LVN_INSERT_MESSAGE notification, on that notification to call a function, but the only way to get the lvitem is throw an lparam, but on_notify has (NMHDR *pNMHDR, LRESULT *pResult) parameters. Can you give me a solution for deallocating that memory, i must insert it with postmessage, don't tell me to use send message or the function insertitem . Thank you.

Était-ce utile?

La solution

Post a custom message to some other window, and in its handler add the item then free memory.

If the list control is already subclassed, there is no need for other window and the message can be sent directly to the control.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top