"Thorsten Kani" beebix@gmx.net 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
revised the patch following your comments. please let me know if you see anything left to do before it can be applied.
Thorsten
Dmitry Timoshkov wrote:
"Thorsten Kani" beebix@gmx.net 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);
- do not use _WIN32_IE version checks in Wine code, they have no sense
- there is no point in setting a pointer to a not initialized buffer
- 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); }
First, thank you both for supporting me in this case (: Actually my totally lack of C knowledge is something i have to work on asap. -- Rob, i have tried your patch and it fixes the problem. seeing my mistake using TBUTTON_INFO as TBBUTTON makes me realize that i wasnt at least too far away from the right track. By the way, your implementation of ImageList_SetColorTable also works fine for me.
I still have one question regarding the relation of NMTOOLBAR.pszText and TBBUTTON.iString: You did not use nmtoolbar.pszText here. Is it optional, because its already in the TBButton struct ? If yes - what about nmtoolbar.rect then ?
Tho
Thorsten Kani wrote:
Rob, i have tried your patch and it fixes the problem.
Good. I've sent it to wine-patches. Thanks for reporting these problems, providing patches and testing proposed patches.
By the way, your implementation of ImageList_SetColorTable also works fine for me.
Good. I should have the other two functions done soon.
I still have one question regarding the relation of NMTOOLBAR.pszText and TBBUTTON.iString: You did not use nmtoolbar.pszText here. Is it optional, because its already in the TBButton struct ?
Presumably so. NMTOOLBAR.pszText only seems to be used by the TBN_GETBUTTONINFO notification.
If yes - what about nmtoolbar.rect then ?
AFAIK, that is only used by TBN_DROPDOWN (not documented on MSDN) and is used so that the popup menu appears in the correct place (just below the button).
Please keep reporting any problems using comctl32 on Win2k. In particular, I would be interested in knowing if the Start Menu looks correct.
Rob
Hi, I took a look at the Startmenu. It does its job except for the following minor problems:
-Keyboard input is completely ignored -Icon Backgrounds are white instead of grey -All the Icons were drawn a few pixels below where they belong, wich makes them a bit overdrawn by the Icon below. -The Strings above the seperator were drawn next to the right border wich makes them partially overdrawn by the Buttons Icon. (Strings and Buttons beyond the seperator are drawn right)
If the mouse hovers over the button, the text redraws at the right place
Tho
Thorsten Kani wrote:
Hi, I took a look at the Startmenu. It does its job except for the following minor problems:
-Keyboard input is completely ignored -Icon Backgrounds are white instead of grey -All the Icons were drawn a few pixels below where they belong, wich makes them a bit overdrawn by the Icon below. -The Strings above the seperator were drawn next to the right border wich makes them partially overdrawn by the Buttons Icon. (Strings and Buttons beyond the seperator are drawn right)
Could you send a screenshot to show the visual issues?
Thanks,
Rob
...now with screenshots included.
Hi, I took a look at the Startmenu. It does its job except for the following minor problems:
-Keyboard input is completely ignored -Icon Backgrounds are white instead of grey -All the Icons were drawn a few pixels below where they belong, wich makes them a bit overdrawn by the Icon below. -The Strings above the seperator were drawn next to the* *_left_ border wich makes them partially overdrawn by the Buttons Icon.
Tho
Thorsten Kani wrote:
...now with screenshots included.
Hi, I took a look at the Startmenu. It does its job except for the following minor problems:
-Keyboard input is completely ignored -Icon Backgrounds are white instead of grey -All the Icons were drawn a few pixels below where they belong, wich makes them a bit overdrawn by the Icon below. -The Strings above the seperator were drawn next to the* *_left_ border wich makes them partially overdrawn by the Buttons Icon.
Thanks. Could you try the attached patch which should fix the white background issue? Also, could you try setting both OFFSET_X and OFFSET_Y to 0 in wine/dlls/comctl32/toolbar.c The strings being in the wrong position is a bigger issue. If you are interested, the problem is that we recalculate and redraw our toolbar control too much so that the code to create the Start Menu expects that it won't be refreshed until it has finished setting the various properties of the toolbar. I have some unfinished work in the toolbar control at the moment, but I plan to use controlspy to see which messages should cause a redraw and which shouldn't.
Rob
Index: wine/dlls/comctl32/toolbar.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/toolbar.c,v retrieving revision 1.195 diff -u -p -r1.195 toolbar.c --- wine/dlls/comctl32/toolbar.c 18 Oct 2004 19:39:22 -0000 1.195 +++ wine/dlls/comctl32/toolbar.c 19 Oct 2004 16:17:42 -0000 @@ -707,7 +707,7 @@ TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, BOOL draw_masked = FALSE; INT index; INT offset = 0; - UINT draw_flags = ILD_NORMAL; + UINT draw_flags = ILD_TRANSPARENT;
if (tbcd->nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE)) { @@ -5370,7 +5434,6 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam infoPtr->nOldHit = -1; infoPtr->nHotItem = -1; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; - infoPtr->bUnicode = IsWindowUnicode (infoPtr->hwndNotify); infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST)); infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS: DT_CENTER | DT_END_ELLIPSIS; infoPtr->bAnchor = FALSE; /* no anchor highlighting */ @@ -5388,7 +5451,8 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam infoPtr->dwStyle = dwStyle; infoPtr->tbim.iButton = -1; GetClientRect(hwnd, &infoPtr->client_rect); - TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY); + infoPtr->bUnicode = infoPtr->hwndNotify && + (NFR_UNICODE == SendMessageW(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, (LPARAM)NF_REQUERY));
SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont); @@ -6385,25 +6434,24 @@ TOOLBAR_NotifyFormatFake(HWND hwnd, WPAR static LRESULT TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - INT i; + LRESULT format;
TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam, lParam);
- if ((lParam == NF_QUERY) && ((HWND)wParam == infoPtr->hwndToolTip)) + if (lParam == NF_QUERY) return NFR_UNICODE;
if (lParam == NF_REQUERY) { - i = SendMessageW(infoPtr->hwndNotify, + format = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY); - if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { - ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", - i); - i = NFR_ANSI; + if ((format != NFR_ANSI) && (format != NFR_UNICODE)) { + ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n", + format); + format = NFR_ANSI; } - infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0; - return (LRESULT)i; + return format; } - return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); + return 0; }