-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. Following my first post on this topic, I'm submitting a new patch to implement the TB_REPLACEBITMAP message in toolbar.c. The test application I've used (a spare parts catalogue on CD from IVECO), now works fine with this, and displays correctly the toolbar. The implementation is still not complete (it does not handle hInst == -1 or on a different module), and cases when the images to be replaced are less than the full toolbar. I hope I will be able to release a full implementation in the next days. Any comment is appreciated. - -- Marco Bizzarri - Responsabile Tecnico - Icube S.r.l. Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia E-mail: m.bizzarri@icube.it WWW: www.icube.it Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://quantumlab.net/pine_privacy_guard/ iD8DBQE7+6aeXhfyAQQVoaIRAoeAAJ9HCbDL7zz5+V1Mgt9HwXgZKy3ukwCgoqVV idzFzKxgECD11z6SFq+JBZk= =1YDM -----END PGP SIGNATURE-----
--- dlls/comctl32/toolbar.c Wed Nov 21 13:59:37 2001 +++ dlls/comctl32/toolbar.c.patched Wed Nov 21 13:59:01 2001 @@ -75,6 +75,13 @@ typedef struct { + UINT nButtons; + HINSTANCE hInst; + UINT nID; +} TBITMAP_INFO; + +typedef struct +{ DWORD dwStructSize; /* size of TBBUTTON struct */ INT nHeight; /* height of the toolbar */ INT nWidth; /* width of the toolbar */ @@ -90,6 +97,7 @@ INT nNumButtons; /* number of buttons */ INT nNumBitmaps; /* number of bitmaps */ INT nNumStrings; /* number of strings */ + INT nNumBitmapInfos; BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */ BOOL bCaptured; /* mouse captured? */ INT nButtonDown; @@ -117,6 +125,7 @@ TBUTTON_INFO *buttons; /* pointer to button array */ LPWSTR *strings; /* pointer to string array */ + TBITMAP_INFO *bitmaps; } TOOLBAR_INFO, *PTOOLBAR_INFO; @@ -1988,7 +1997,27 @@ DeleteObject (hbmLoad); } - if (nIndex != -1) + TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos); + + if (infoPtr->nNumBitmapInfos == 0) + { + infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO)); + } + else + { + TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps; + infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO)); + memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos); + } + + infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons; + infoPtr->bitmaps[infoPtr->nNumBitmapInfos].hInst = lpAddBmp->hInst; + infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nID = lpAddBmp->nID; + + infoPtr->nNumBitmapInfos++; + TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos); + + if (nIndex != -1) { INT imagecount = ImageList_GetImageCount(infoPtr->himlDef); @@ -3382,8 +3411,71 @@ } -/* << TOOLBAR_ReplaceBitmap >> */ +static LRESULT +TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); + LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam; + HBITMAP hBitmap; + int i = 0, nOldButtons = 0, pos = 0; + + TRACE("hInstOld %x nIDOld %x hInstNew %x nIDNew %x nButtons %x\n", + lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew, + lpReplace->nButtons); + + if (lpReplace->hInstOld == -1) + { + FIXME("changing standard bitmaps not implemented\n"); + return FALSE; + } + else if (lpReplace->hInstOld != 0) + { + FIXME("resources not in the current module not implemented\n"); + return FALSE; + } + else + { + hBitmap = (HBITMAP) lpReplace->nIDNew; + } + + TRACE("To be replaced hInstOld %x nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld); + for (i = 0; i < infoPtr->nNumBitmapInfos; i++) { + TBITMAP_INFO *tbi = &infoPtr->bitmaps[i]; + TRACE("tbimapinfo %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID); + if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld) + { + TRACE("Found: nButtons %d hInst %x nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID); + nOldButtons = tbi->nButtons; + tbi->nButtons = lpReplace->nButtons; + tbi->hInst = lpReplace->hInstNew; + tbi->nID = lpReplace->nIDNew; + TRACE("tbimapinfo changed %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID); + break; + } + pos += tbi->nButtons; + } + + if (nOldButtons == 0) + { + WARN("No hinst/bitmap found! hInst %x nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld); + return FALSE; + } + + infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons; + + // ImageList_Replace(infoPtr->himlDef, pos, hBitmap, NULL); + + + for (i = pos + nOldButtons - 1; i >= pos; i--) { + ImageList_Remove(infoPtr->himlDef, i); + } + + ImageList_AddMasked(infoPtr->himlDef, hBitmap, CLR_DEFAULT); + InvalidateRect(hwnd, NULL, FALSE); + + return TRUE; +} static LRESULT TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam) @@ -5032,7 +5124,8 @@ case TB_PRESSBUTTON: return TOOLBAR_PressButton (hwnd, wParam, lParam); -/* case TB_REPLACEBITMAP: */ + case TB_REPLACEBITMAP: + return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam); case TB_SAVERESTOREA: return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);