+bool wxCheckListBox::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
+{
+ // prepare the event
+ // -----------------
+
+ wxCommandEvent event(wxEVT_NULL, m_windowId);
+ event.SetEventObject(this);
+
+ wxEventType eventType = wxEVT_NULL;
+
+ NMHDR *nmhdr = (NMHDR *)lParam;
+
+ if ( nmhdr->hwndFrom == GetHwnd() )
+ {
+ // 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_COMMAND_CHECKLISTBOX_TOGGLED);
+ event.SetInt(IsChecked(iItem));
+ (void) GetEventHandler()->ProcessEvent(event);
+ }
+
+ if ( (stNew & LVIS_SELECTED) != (stOld & LVIS_SELECTED) )
+ {
+ eventType = wxEVT_COMMAND_LISTBOX_SELECTED;
+
+ 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;
+ }
+
+ // process the event
+ // -----------------
+
+ event.SetEventType(eventType);
+
+ bool processed = GetEventHandler()->ProcessEvent(event);
+ if ( processed )
+ *result = 0;
+
+ return processed;
+}
+
+