Implementation of TB_REPLACEBITMAP
Marco Bizzarri
m.bizzarri at icube.it
Tue Nov 20 10:30:12 CST 2001
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all.
I'm trying to provide an implementation of TB_REPLACEBITMAP
Included is the patch I've done to record the bitmaps which are provided
to the toolbar and to replace them when the message arrives.
Even though the number of buttons displayed is correct, the output is
otherwise garbled. I would appreciate any suggestion on this topic.
The platform is a RH Linux 6.2.
wine is from CVS (20/11/2001)
- --
Marco Bizzarri - Responsabile Tecnico - Icube S.r.l.
Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: m.bizzarri at 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+oUXXhfyAQQVoaIRAudsAJ9QEbPYChk0YpTonozvkjUge4HtjACgl8cg
A87v4vPHKOeeCgj6LpW18dw=
=J2rq
-----END PGP SIGNATURE-----
-------------- next part --------------
--- toolbar.c Tue Nov 20 17:22:28 2001
+++ toolbar.c.new Tue Nov 20 17:20:24 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,64 @@
}
-/* << 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;
+ TRACE("New bitmaps: %d pos %d\n", infoPtr->nNumBitmaps, pos);
+
+ ImageList_Replace(infoPtr->himlDef, pos, hBitmap, NULL);
+ InvalidateRect(hwnd, NULL, FALSE);
+
+ return TRUE;
+}
static LRESULT
TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
@@ -5032,7 +5117,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);
More information about the wine-devel
mailing list