1

I'm handling the LVN_ITEMCHANGING message, but it gets signaled every time the check state is changed.

I need a way to distinguish between the user changing the check state, and me calling ListView_SetCheckState

Is there any easy way to do this? A different message I don't know about maybe? Or does anyone have any suggestions?

4

1 に答える 1

3

ListView_SetCheckState sends the LVM_SETITEMSTATE message. LVN_ITEMCHANGING message is also sent to the control's parent window. This means, the function is synchronous, and LVN_ITEMCHANGING handler is executed before ListView_SetCheckState call returns. This allows to use simple boolean flag, like:

bChangedByProgram = TRUE;
ListView_SetCheckState(...);
bChangedByProgram = FALSE;

In LVN_ITEMCHANGING handler:

if ( ! bChangedByProgram )
{
    // item state is changed by user
}
于 2012-08-17T18:42:36.527 に答える