With my listview I am using LVN_ITEMCHANGED to evaluate the row when a checkbox is checked. My problem is that if I click on another row in the listview the LVN_ITEMCHANGED is fired again and of course it reevaluates the data with wrong results.
The event is checked by a if Statement
If GetFocus() = HWND_JOBFORM_LISTVIEW1 And @lpNMV.iSubItem = 0 then
is used to make sure that only an event in column 0 will fire the evaluation. But it seems that if I click again in the grid another row is selected and .iSubItem is still 0 and fulfills my condition and reevaluates. So I am thinking that I am using putting my code in the wrong event.
Is there another place where I can fire my routine when a checkbox is being checked or unchecked?
thanx
bert
In general, you should use the ListView_GetCheckState( hWndControl, @lpNMV.iItem ) macro to retrieve the state of your checkbox. Whenever the active row changes or an element of that row changes, the LVN_ITEMCHANGED notification will fire.
I found the following code on POFFS that should isolate your logic within the LVN_ITEMCHANGED notification:
%LVSTATE_CHECKED = &H2000 ' ListView item is checked
%LVSTATE_UNCHECKED = &H1000 ' ListView item is UNchecked
If (@lpNMV.iSubItem = 0 ) And _
(@lpNMV.uOldState = %LVSTATE_UNCHECKED) Or _
(@lpNMV.uOldState = %LVSTATE_CHECKED) Then
MsgBox "checkbox clicked"
End If
There could be a better way to do this..... not sure.
Thanx Paul, I will try it tonight and give you results
Bert
Update: Works just the way I wanted it.
What keyword did you use to look it up in Poff. I had no luck even finding the code you wrote.