Treeview: Determine whether to do label edit before sending NM_CLICK

Robert Shearman rob at codeweavers.com
Tue Sep 28 07:02:47 CDT 2004


Hi,

When the Explorer treeview processes the NM_CLICK message it likes to 
fiddle about with the current selection and so this always triggers a 
label edit, even when it shouldn't.

Rob

Changelog:
Determine whether to do label edit before sending NM_CLICK.
-------------- next part --------------
Index: wine/dlls/comctl32/treeview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v
retrieving revision 1.152
diff -u -p -r1.152 treeview.c
--- wine/dlls/comctl32/treeview.c	23 Sep 2004 22:51:29 -0000	1.152
+++ wine/dlls/comctl32/treeview.c	26 Sep 2004 20:59:31 -0000
@@ -3779,7 +3779,7 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *info
 {
     HWND hwnd = infoPtr->hwnd;
     TVHITTESTINFO ht;
-    BOOL bTrack;
+    BOOL bTrack, bDoLabelEdit;
     HTREEITEM tempItem;
 
     /* If Edit control is active - kill it and return.
@@ -3812,6 +3812,13 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *info
     bTrack = (ht.flags & TVHT_ONITEM)
 	&& !(infoPtr->dwStyle & TVS_DISABLEDRAGDROP);
 
+    /*
+     * If the style allows editing and the node is already selected
+     * and the click occurred on the item label...
+     */
+    bDoLabelEdit = (infoPtr->dwStyle & TVS_EDITLABELS) &&
+        (ht.flags & TVHT_ONITEMLABEL) && (infoPtr->selectedItem == ht.hItem);
+
     /* Send NM_CLICK right away */
     if (!bTrack)
 	if (TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK))
@@ -3848,12 +3855,7 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *info
     if (bTrack && TREEVIEW_SendSimpleNotify(infoPtr, NM_CLICK))
         goto setfocus;
 
-    /*
-     * If the style allows editing and the node is already selected
-     * and the click occurred on the item label...
-     */
-    if ((infoPtr->dwStyle & TVS_EDITLABELS) &&
-	        (ht.flags & TVHT_ONITEMLABEL) && (infoPtr->selectedItem == ht.hItem))
+    if (bDoLabelEdit)
     {
 	if (infoPtr->Timer & TV_EDIT_TIMER_SET)
 	    KillTimer(hwnd, TV_EDIT_TIMER);


More information about the wine-patches mailing list