Toolbar: More Notification Fixes

Robert Shearman rob at codeweavers.com
Sat Oct 23 05:38:21 CDT 2004


Hi,

The first fix is to remove the passing unnecessary information in 
certain notification messages (along with removing confusing comments). 
It is probably won't break anything to leave it as is, but it will help 
with maintainance.
The second fix is a signedness issue where the current code does 
"nmmouse.dwHitInfo < 0" which will always be false, resulting in a crash 
in certain circumstances.

Rob

Changelog:
- Don't fill in any more information than native does for notifications.
- Store hit code in a signed integer so that we can see whether it is 
less than zero.
-------------- next part --------------
Index: wine/dlls/comctl32/toolbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/toolbar.c,v
retrieving revision 1.197
diff -u -p -r1.197 toolbar.c
--- wine/dlls/comctl32/toolbar.c	21 Oct 2004 20:58:43 -0000	1.197
+++ wine/dlls/comctl32/toolbar.c	23 Oct 2004 10:12:32 -0000
@@ -5632,11 +5696,9 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM w
 	    RedrawWindow(hwnd,&btnPtr->rect,0,
 			RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
 
+	    memset(&nmtb, 0, sizeof(nmtb));
 	    nmtb.iItem = btnPtr->idCommand;
-	    memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
-	    nmtb.cchText = 0;
-	    nmtb.pszText = 0;
-	    CopyRect(&nmtb.rcButton, &btnPtr->rect);
+	    nmtb.rcButton = btnPtr->rect;
 	    res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
 				  TBN_DROPDOWN);
 	    TRACE("TBN_DROPDOWN responded with %ld\n", res);
@@ -5686,22 +5748,15 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM w
 
     if (nHit >=0)
     {
+        memset(&nmtb, 0, sizeof(nmtb));
         nmtb.iItem = btnPtr->idCommand;
-        nmtb.tbButton.iBitmap = btnPtr->iBitmap;
-        nmtb.tbButton.idCommand = btnPtr->idCommand;
-        nmtb.tbButton.fsState = btnPtr->fsState;
-        nmtb.tbButton.fsStyle = btnPtr->fsStyle;
-        nmtb.tbButton.dwData = btnPtr->dwData;
-        nmtb.tbButton.iString = btnPtr->iString;
-        nmtb.cchText = 0;  /* !!! not correct */
-        nmtb.pszText = 0;  /* !!! not correct */
         TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_BEGINDRAG);
     }
 
     nmmouse.dwHitInfo = nHit;
 
     /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
-    if (nmmouse.dwHitInfo < 0)
+    if (nHit < 0)
         nmmouse.dwItemSpec = -1;
     else
     {
@@ -5847,15 +5902,8 @@ TOOLBAR_LButtonUp (HWND hwnd, WPARAM wPa
 	/* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
 	 * TBN_BEGINDRAG
 	 */
+	memset(&nmtb, 0, sizeof(nmtb));
 	nmtb.iItem = btnPtr->idCommand;
-	nmtb.tbButton.iBitmap = btnPtr->iBitmap;
-	nmtb.tbButton.idCommand = btnPtr->idCommand;
-	nmtb.tbButton.fsState = btnPtr->fsState;
-	nmtb.tbButton.fsStyle = btnPtr->fsStyle;
-	nmtb.tbButton.dwData = btnPtr->dwData;
-	nmtb.tbButton.iString = btnPtr->iString;
-	nmtb.cchText = 0;  /* !!! not correct */
-	nmtb.pszText = 0;  /* !!! not correct */
 	TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
 			TBN_ENDDRAG);
 
@@ -5891,16 +5939,17 @@ static LRESULT
 TOOLBAR_RButtonUp( HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
-
+    INT nHit;
     NMMOUSE nmmouse;
     POINT pt;
 
     pt.x = LOWORD(lParam);
     pt.y = HIWORD(lParam);
 
-    nmmouse.dwHitInfo = TOOLBAR_InternalHitTest(hwnd, &pt);
+    nHit = TOOLBAR_InternalHitTest(hwnd, &pt);
+    nmmouse.dwHitInfo = nHit;
 
-    if (nmmouse.dwHitInfo < 0) {
+    if (nHit < 0) {
 	nmmouse.dwItemSpec = -1;
     } else {
 	nmmouse.dwItemSpec = infoPtr->buttons[nmmouse.dwHitInfo].idCommand;


More information about the wine-patches mailing list