listview: fix LVN_ITEMACTIVATE notifications

Andreas Mohr andi at rhlx01.fht-esslingen.de
Sun Dec 15 12:01:23 CST 2002


Hi all,

LVN_ITEMACTIVATE was sort of ill-implemented:
it was sending only the outdated NMHDR format, and only a double-click
sent it (instead of a single-click).

Note that this is just a bare-bones patch to make some programs work.
It's by no means a complete solution (it's just meant to fix the worst
problems).
(which values should NMITEMACTIVATE have ? When exactly to send
LVN_ITEMACTIVATE at all ??)

- send a full NMITEMACTIVATE struct instead of the outdated NMHDR
- also send LVN_ITEMACTIVATE on single-click

Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.333
diff -u -r1.333 listview.c
--- dlls/comctl32/listview.c	10 Dec 2002 19:07:27 -0000	1.333
+++ dlls/comctl32/listview.c	15 Dec 2002 18:02:29 -0000
@@ -708,9 +708,36 @@
     return notify_hdr(infoPtr, code, &nmh);
 }
 
-static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr)
+static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr, POINT *pt)
 {
-    notify(infoPtr, LVN_ITEMACTIVATE);
+    NMITEMACTIVATE nmia;
+    LRESULT result;
+    
+    nmia.hdr.hwndFrom = infoPtr->hwndSelf;
+    nmia.hdr.idFrom = GetWindowLongW(infoPtr->hwndSelf, GWL_ID);
+    nmia.hdr.code = LVN_ITEMACTIVATE;
+    nmia.iItem = infoPtr->nFocusedItem;
+    nmia.iSubItem = 0; /* FIXME */
+    nmia.uNewState = 1; /* FIXME */
+    nmia.uOldState = 0; /* FIXME */
+    nmia.uChanged = 0; /* FIXME */
+    if (pt)
+        nmia.ptAction = *pt;
+    nmia.lParam = 0; /* FIXME */
+    nmia.uKeyFlags = 0;
+    if (GetKeyState(VK_MENU) & 0x8000)
+	nmia.uKeyFlags |= LVKF_ALT;
+    if (GetKeyState(VK_CONTROL) & 0x8000)
+	nmia.uKeyFlags |= LVKF_CONTROL;
+    if (GetKeyState(VK_SHIFT) & 0x8000)
+	nmia.uKeyFlags |= LVKF_SHIFT;
+
+    TRACE("(%d, keys %d)\n", nmia.iItem, nmia.uKeyFlags);
+
+    result = SendMessageW(GetParent(infoPtr->hwndSelf), WM_NOTIFY,
+			  (WPARAM)nmia.hdr.idFrom, (LPARAM)&nmia);
+
+    TRACE("  <= %ld\n", result);
 }
 
 static inline LRESULT notify_listview(LISTVIEW_INFO *infoPtr, INT code, LPNMLISTVIEW plvnm)
@@ -7391,7 +7418,7 @@
     if ((infoPtr->nItemCount > 0) && (infoPtr->nFocusedItem != -1))
     {
       notify(infoPtr, NM_RETURN);
-      notify(infoPtr, LVN_ITEMACTIVATE);
+      notify_itemactivate(infoPtr, NULL);
     }
     break;
 
@@ -7507,7 +7534,7 @@
     notify_click(infoPtr, NM_DBLCLK, &htInfo);
 
     /* To send the LVN_ITEMACTIVATE, it must be on an Item */
-    if(htInfo.iItem != -1) notify(infoPtr, LVN_ITEMACTIVATE);
+    if(htInfo.iItem != -1) notify_itemactivate(infoPtr, &htInfo.pt);
 
     return 0;
 }
@@ -7546,6 +7573,7 @@
 
   nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
   TRACE("at %s, nItem=%d\n", debugpoint(&pt), nItem);
+
   infoPtr->nEditLabelItem = -1;
   if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
   {
@@ -7601,6 +7629,8 @@
         LISTVIEW_SetSelection(infoPtr, nItem);
       }
     }
+    /* To send the LVN_ITEMACTIVATE, it must be on an Item */
+    if(lvHitTestInfo.iItem != -1) notify_itemactivate(infoPtr, &lvHitTestInfo.pt);
   }
   else
   {
Index: include/commctrl.h
===================================================================
RCS file: /home/wine/wine/include/commctrl.h,v
retrieving revision 1.100
diff -u -r1.100 commctrl.h
--- include/commctrl.h	18 Nov 2002 19:45:47 -0000	1.100
+++ include/commctrl.h	15 Dec 2002 18:02:32 -0000
@@ -3068,6 +3068,10 @@
     UINT uKeyFlags;
 } NMITEMACTIVATE, *LPNMITEMACTIVATE;
 
+#define LVKF_ALT	0x0001
+#define LVKF_CONTROL	0x0002
+#define LVKF_SHIFT	0x0004
+
 typedef struct tagLVDISPINFOA
 {
     NMHDR hdr;

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany



More information about the wine-patches mailing list