+// we hook into WndProc to process WM_MOUSEMOVE/WM_BUTTONUP messages - as we
+// only do it during dragging, minimize wxWin overhead (this is important for
+// WM_MOUSEMOVE as they're a lot of them) by catching Windows messages directly
+// instead of passing by wxWin events
+long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+ if ( m_dragImage )
+ {
+ switch ( nMsg )
+ {
+ case WM_MOUSEMOVE:
+ {
+ int x = GET_X_LPARAM(lParam),
+ y = GET_Y_LPARAM(lParam);
+
+ m_dragImage->Move(wxPoint(x, y), this);
+
+ HTREEITEM htiTarget = GetItemFromPoint(GetHwnd(), x, y);
+ if ( htiTarget )
+ {
+ // highlight the item as target (hiding drag image is
+ // necessary - otherwise the display will be corrupted)
+ m_dragImage->Hide(this);
+ TreeView_SelectDropTarget(GetHwnd(), htiTarget);
+ m_dragImage->Show(this);
+ }
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ {
+ m_dragImage->EndDrag(this);
+ delete m_dragImage;
+ m_dragImage = NULL;
+
+ // generate the drag end event
+ wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, m_windowId);
+
+ int x = GET_X_LPARAM(lParam),
+ y = GET_Y_LPARAM(lParam);
+
+ event.m_item
+ = (WXHTREEITEM)GetItemFromPoint(GetHwnd(), x, y);
+ event.m_pointDrag = wxPoint(x, y);
+ event.SetEventObject(this);
+
+ (void)GetEventHandler()->ProcessEvent(event);
+ }
+ break;
+ }
+ }
+
+ return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+