Dmitry Timoshkov wrote:

"Thorsten Kani" <[EMAIL PROTECTED]> wrote:



I'm a bit unsure about my solution, but actually everything works.
-complaints appreciated-
--- toolbar.c 23 Sep 2004 22:51:14 -0000 1.194
+++ toolbar.c 10 Oct 2004 17:29:01 -0000
@@ -3191,12 +3191,20 @@
    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    INT nIndex = (INT)wParam;
    NMTOOLBARW nmtb;
+    WCHAR Buffer[256];

    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
 return FALSE;

memset(&nmtb, 0, sizeof(nmtb));
nmtb.iItem = nIndex;
+ memcpy(&nmtb.tbButton, &infoPtr->buttons[nIndex], sizeof(nmtb.tbButton) );
+ nmtb.cchText = 256;
+ nmtb.pszText = Buffer;
+#if (_WIN32_IE >= 0x500) + nmtb.rcButton =(RECT)infoPtr->buttons[nIndex].rect;
+#endif
+
TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_DELETINGBUTTON);



1. do not use _WIN32_IE version checks in Wine code, they have no sense
2. there is no point in setting a pointer to a not initialized buffer
3. there is no need to cast RECT to a RECT


4. TBN_DELETINGBUTTON doesn't have A/W versions so it can't use a text buffer.
5. You can't use memcpy because TBUTTON_INFO isn't the same as TBBUTTON


Thorsten, please try the attached patch.

Rob
Index: wine/dlls/comctl32/toolbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/toolbar.c,v
retrieving revision 1.194
diff -u -p -r1.194 toolbar.c
--- wine/dlls/comctl32/toolbar.c        23 Sep 2004 22:51:14 -0000      1.194
+++ wine/dlls/comctl32/toolbar.c        17 Oct 2004 18:12:38 -0000
@@ -1801,8 +1801,9 @@ static void TOOLBAR_Cust_MoveButton(PCUS
     if (nIndexFrom == nIndexTo)
         return;
 
-    /* send TBN_QUERYINSERT notification */
-    nmtb.iItem = nIndexFrom; /* FIXME: this doesn't look right */
+    /* MSDN states that iItem is the index of the button, rather than the
+     * command ID as used by every other NMTOOLBAR notification */
+    nmtb.iItem = nIndexFrom;
     if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
     {
         PCUSTOMBUTTON btnInfo;
@@ -1841,8 +1842,9 @@ static void TOOLBAR_Cust_AddButton(PCUST
 
     TRACE("Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail, nIndexTo);
 
-    /* send TBN_QUERYINSERT notification */
-    nmtb.iItem = nIndexAvail; /* FIXME: this doesn't look right */
+    /* MSDN states that iItem is the index of the button, rather than the
+     * command ID as used by every other NMTOOLBAR notification */
+    nmtb.iItem = nIndexAvail;
     if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT))
     {
         PCUSTOMBUTTON btnInfo;
@@ -3191,16 +3193,23 @@ TOOLBAR_DeleteButton (HWND hwnd, WPARAM 
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     INT nIndex = (INT)wParam;
     NMTOOLBARW nmtb;
+    TBUTTON_INFO *btnPtr = &infoPtr->buttons[nIndex];
 
     if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
-       return FALSE;
+        return FALSE;
 
     memset(&nmtb, 0, sizeof(nmtb));
-    nmtb.iItem = nIndex;
+    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;
     TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_DELETINGBUTTON);
 
     if ((infoPtr->hwndToolTip) &&
-       !(infoPtr->buttons[nIndex].fsStyle & BTNS_SEP)) {
+       !(btnPtr->fsStyle & BTNS_SEP)) {
        TTTOOLINFOW ti;
 
        ZeroMemory (&ti, sizeof(ti));
@@ -7167,10 +7176,12 @@ static BOOL TOOLBAR_GetButtonInfo(TOOLBA
 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr,
        int iItem, PCUSTOMBUTTON btnInfo)
 {
-    NMTOOLBARA nmtb;
+    NMTOOLBARW nmtb;
 
+    /* MSDN states that iItem is the index of the button, rather than the
+     * command ID as used by every other NMTOOLBAR notification */
     nmtb.iItem = iItem;
     memcpy(&nmtb.tbButton, &btnInfo->btn, sizeof(TBBUTTON));
 
-    return TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYDELETE);
+    return TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYDELETE);
 }

Reply via email to