+ case NM_RCLICK:
+ {
+ eventType = wxEVT_COMMAND_LIST_COL_RIGHT_CLICK;
+ event.m_col = -1;
+
+ // find the column clicked: we have to search for it
+ // ourselves as the notification message doesn't provide
+ // this info
+
+ // where did the click occur?
+ POINT ptClick;
+ if ( !::GetCursorPos(&ptClick) )
+ {
+ wxLogLastError(_T("GetCursorPos"));
+ }
+
+ if ( !::ScreenToClient(hwndHdr, &ptClick) )
+ {
+ wxLogLastError(_T("ScreenToClient(listctrl header)"));
+ }
+
+ event.m_pointDrag.x = ptClick.x;
+ event.m_pointDrag.y = ptClick.y;
+
+ int colCount = Header_GetItemCount(hwndHdr);
+
+ RECT rect;
+ for ( int col = 0; col < colCount; col++ )
+ {
+ if ( Header_GetItemRect(hwndHdr, col, &rect) )
+ {
+ if ( ::PtInRect(&rect, ptClick) )
+ {
+ event.m_col = col;
+ break;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ return wxControl::MSWOnNotify(idCtrl, lParam, result);
+ }
+ }
+ else
+#endif // defined(HDN_BEGINTRACKA)
+ if ( nmhdr->hwndFrom == GetHwnd() )
+ {
+ // almost all messages use NM_LISTVIEW
+ NM_LISTVIEW *nmLV = (NM_LISTVIEW *)nmhdr;
+
+ // this is true for almost all events
+ event.m_item.m_data = nmLV->lParam;
+
+ switch ( nmhdr->code )
+ {
+ case LVN_BEGINRDRAG:
+ eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
+ // fall through
+
+ case LVN_BEGINDRAG:
+ if ( eventType == wxEVT_NULL )
+ {
+ eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
+ }
+
+ event.m_itemIndex = nmLV->iItem;
+ event.m_pointDrag.x = nmLV->ptAction.x;
+ event.m_pointDrag.y = nmLV->ptAction.y;
+ break;
+
+ // NB: we have to handle both *A and *W versions here because some
+ // versions of comctl32.dll send ANSI message to an Unicode app
+ case LVN_BEGINLABELEDITA:
+ {
+ eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
+ wxLV_ITEM item(((LV_DISPINFOA *)lParam)->item);
+ wxConvertFromMSWListItem(GetHwnd(), event.m_item, item);
+ event.m_itemIndex = event.m_item.m_itemId;
+ }
+ break;
+ case LVN_BEGINLABELEDITW:
+ {
+ eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
+ wxLV_ITEM item(((LV_DISPINFOW *)lParam)->item);
+ wxConvertFromMSWListItem(GetHwnd(), event.m_item, item);
+ event.m_itemIndex = event.m_item.m_itemId;
+ }
+ break;
+
+ case LVN_ENDLABELEDITA:
+ {
+ eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
+ wxLV_ITEM item(((LV_DISPINFOA *)lParam)->item);
+ wxConvertFromMSWListItem(NULL, event.m_item, item);
+ if ( ((LV_ITEM)item).pszText == NULL ||
+ ((LV_ITEM)item).iItem == -1 )
+ return FALSE;
+
+ event.m_itemIndex = event.m_item.m_itemId;
+ }
+ break;
+ case LVN_ENDLABELEDITW:
+ {
+ eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
+ wxLV_ITEM item(((LV_DISPINFOW *)lParam)->item);
+ wxConvertFromMSWListItem(NULL, event.m_item, item);
+ if ( ((LV_ITEM)item).pszText == NULL ||
+ ((LV_ITEM)item).iItem == -1 )
+ return FALSE;
+
+ event.m_itemIndex = event.m_item.m_itemId;
+ }
+ break;
+
+ case LVN_COLUMNCLICK: