Thank you very much, Mr Cvetanović .
Your answer is what I really need.
You mean UWM_UPDATE_LIST is a user-defined message, actually listcontrol and
the parent of listcontrol own the same message queue.
I also planned to send the WM_NOTIFY(LVN_INSERTITEM) message to the parent
dialog, but it is also not right solution.
About
---------------
If wParam and lParam should contain some structs or buffers (like char*)
then create them in worker thread, and delete them in event handler.
---------------
This is also what I'm thinking. If I don't create/new the struct or buffer
in the worker thread, but instead, use the stack, and post the address of
the struct as lParam or wParam to the UI. I'm afraid this will cause UI to
lose some results.
Am I right?
Also one of my colleague says, continuously "new" and "delete" will cause
many memory fragments. Is he right? If he is right, How should I avoid this?
Thank you.
> > So I have to use SendMessage(LVM_XXX, hListCtrl) in the worker thread, I
> > guess.
[quoted text clipped - 9 lines]
> If wParam and lParam should contain some structs or buffers (like char*)
> then create them in worker thread, and delete them in event handler.
Mihajlo Cvetanović - 21 Jun 2005 12:08 GMT
> You mean UWM_UPDATE_LIST is a user-defined message, actually listcontrol and
> the parent of listcontrol own the same message queue.
Yes, that's correct (in this simple case).
> ---------------
> If wParam and lParam should contain some structs or buffers (like char*)
[quoted text clipped - 5 lines]
> lose some results.
> Am I right?
Yes, you're right, if you want to PostMessage to pass structures around
then you must use the heap.
> Also one of my colleague says, continuously "new" and "delete" will cause
> many memory fragments. Is he right? If he is right, How should I avoid this?
If you post structs or classes then they are all of the same size, so
there's no fragmentation. But if you post char* (or char* inside the
struct) AND those buffers are of the various sizes (between 1 byte and 1
megabyte) then there might be fragmentations. However, you shouldn't
think about performances so early, the chances are you wont feel any
slowdown.
So the answer is that he could be right, but that could be irrelevant.
Fragmentation could be avoided if you use buffers of the same size, or
if you "recycle" old buffers, but I repeat you shouldn't worry about
that right now.