- int pos = Append(items[i]);
- if( pos >= 0 && clientData )
- DoSetItemClientData(pos, clientData[i]);
+ // almost all messages use NM_LISTVIEW
+ NM_LISTVIEW *nmLV = (NM_LISTVIEW *)nmhdr;
+
+ const int iItem = nmLV->iItem;
+
+ bool processed = true;
+ switch ( nmhdr->code )
+ {
+ case LVN_ITEMCHANGED:
+ // we translate this catch all message into more interesting
+ // (and more easy to process) wxWidgets events
+
+ // first of all, we deal with the state change events only and
+ // only for valid items (item == -1 for the virtual list
+ // control)
+ if ( nmLV->uChanged & LVIF_STATE && iItem != -1 )
+ {
+ // temp vars for readability
+ const UINT stOld = nmLV->uOldState;
+ const UINT stNew = nmLV->uNewState;
+
+ // Check image changed
+ if ((stOld & LVIS_STATEIMAGEMASK) != (stNew & LVIS_STATEIMAGEMASK))
+ {
+ event.SetEventType(wxEVT_CHECKLISTBOX);
+ event.SetInt(IsChecked(iItem));
+ (void) GetEventHandler()->ProcessEvent(event);
+ }
+
+ if ( (stNew & LVIS_SELECTED) != (stOld & LVIS_SELECTED) )
+ {
+ eventType = wxEVT_LISTBOX;
+
+ event.SetExtraLong( (stNew & LVIS_SELECTED) != 0 ); // is a selection
+ event.SetInt(iItem);
+ }
+ }
+
+ if ( eventType == wxEVT_NULL )
+ {
+ // not an interesting event for us
+ return false;
+ }
+
+ break;
+
+ default:
+ processed = false;
+ }
+
+ if ( !processed )
+ return wxControl::MSWOnNotify(idCtrl, lParam, result);
+ }
+ else
+ {
+ // where did this one come from?
+ return false;