I fill a listview in my WM_CREATE and I need to process ListView notification via WM_NOTIFY only if WM_CREATE has finished filling my listview.
My idea is this. I create a critical section and I enter the critical section at the beginning of WM_CREATE.
Then I leave Critical Section at the end of WM_CREATE
In my WM_NOTIFY i use TryEnterCrit.... to see if the ListView is full or not.

The problem is that TryEnter... requires WINNT >= 4000. I need something that works also on Win9x.

Any idea?
Posted on 2004-09-21 15:30:08 by greenant
Perhaps you could use an EVENT to signal that the listview is full? WaitForSingleObject accepts a timeout parameter...
Posted on 2004-09-21 15:35:31 by f0dder
Thanks.
if dwMilliseconds is zero, the function tests the object's state and returns immediately
Posted on 2004-09-21 15:36:49 by greenant
And it's probably not worth testing whether a very small timeout is better than just testing if the event is set, as the message queue is synchroneous.
Posted on 2004-09-21 15:40:15 by f0dder
I don't understand.

I have a listview with LVS_EX_CHECKBOXES.

In WM_CREATE I read an array and I check or uncheck the rows according to this array.
In WM_NOTIFY I use LVN_ITEMCHANGED to check whether my row is checked or not and then I set the flag in the array, each time the user changes the check boxes.

The problem is that during WM_CREATE the system sends LVN_ITEMCHANGED each time I call ListView_SetCheckState.
I want to FILTER this
Posted on 2004-09-21 15:49:21 by greenant
Perhaps just keep a global boolean value specifying whether you're done filling the array? If there aren't multiple threads involved, of course...
Posted on 2004-09-21 15:53:21 by f0dder
Now I'm using the boolean variable, but I always prefer syncronization objects

Thanks
Posted on 2004-09-22 02:59:19 by greenant
Synchronization objects have larger overhead, though - and unless you're doing multithreaded code, you don't really need them.
Posted on 2004-09-22 09:21:50 by f0dder