https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67fd29cae04f260273244…
commit 67fd29cae04f2602732440ddd8cabcb4a425f3d1
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Sep 26 02:26:42 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Sep 26 02:26:42 2021 +0200
[IMAGESOFT] Commit db416e39 made toolbar imagelists creating failing because we
overcounted the number of toolbar button bitmaps.
Indeed the count was based on the number of elements in TBBUTTON arrays;
however for some of the toolbars, extra entries corresponding to
separators are present, and thus the resulting number of elements is
always larger than the number of actual buttons for which an image is
associated. Passing this (larger) count to the InitImageList() function
therefore made image insertion fail after a certain point.
Now we pass an exact number of *images* instead.
---
modules/rosapps/applications/imagesoft/floatwindow.c | 10 ++++------
modules/rosapps/applications/imagesoft/mainwnd.c | 6 ++++--
modules/rosapps/applications/imagesoft/misc.c | 8 +++-----
modules/rosapps/applications/imagesoft/misc.h | 4 ++--
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/modules/rosapps/applications/imagesoft/floatwindow.c
b/modules/rosapps/applications/imagesoft/floatwindow.c
index 28b393747c1..da831e1959a 100644
--- a/modules/rosapps/applications/imagesoft/floatwindow.c
+++ b/modules/rosapps/applications/imagesoft/floatwindow.c
@@ -56,7 +56,7 @@ FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
{
HWND hTb;
HIMAGELIST hImageList;
- INT NumButtons;
+ UINT NumButtons;
NumButtons = sizeof(ToolsButtons) / sizeof(ToolsButtons[0]);
@@ -86,8 +86,7 @@ FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
0,
(LPARAM)MAKELONG(16, 16));
- hImageList = InitImageList(NumButtons,
- IDB_TOOLSRECTSEL);
+ hImageList = InitImageList(IDB_TOOLSRECTSEL, NumButtons - 1); // -1 because of
the last separator.
ImageList_Destroy((HIMAGELIST)SendMessage(hTb,
TB_SETIMAGELIST,
@@ -280,7 +279,7 @@ FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
HWND hList;
HWND hButtons;
HIMAGELIST hImageList;
- INT NumButtons;
+ UINT NumButtons;
hList = CreateWindowEx(0,
WC_LISTBOX,
@@ -316,8 +315,7 @@ FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
0,
(LPARAM)MAKELONG(10, 10));
- hImageList = InitImageList(NumButtons,
- IDB_HISTBACK);
+ hImageList = InitImageList(IDB_HISTBACK, NumButtons);
ImageList_Destroy((HIMAGELIST)SendMessage(hButtons,
TB_SETIMAGELIST,
diff --git a/modules/rosapps/applications/imagesoft/mainwnd.c
b/modules/rosapps/applications/imagesoft/mainwnd.c
index 07597022998..551b53ab692 100644
--- a/modules/rosapps/applications/imagesoft/mainwnd.c
+++ b/modules/rosapps/applications/imagesoft/mainwnd.c
@@ -119,6 +119,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
const TBBUTTON *Buttons = NULL;
UINT NumButtons = 0;
UINT StartImageRes = 0;
+ UINT NumImages = 0;
HWND hWndClient = NULL;
UNREFERENCED_PARAMETER(Context);
@@ -130,6 +131,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
Buttons = StdButtons;
NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]);
StartImageRes = IDB_MAINNEWICON;
+ NumImages = 10;
break;
}
@@ -138,6 +140,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
Buttons = TextButtons;
NumButtons = sizeof(TextButtons) / sizeof(TextButtons[0]);
StartImageRes = IDB_TEXTBOLD;
+ NumImages = 6;
break;
}
@@ -194,8 +197,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
0,
(LPARAM)MAKELONG(TB_BMP_WIDTH, TB_BMP_HEIGHT));
- hImageList = InitImageList(NumButtons,
- StartImageRes);
+ hImageList = InitImageList(StartImageRes, NumImages);
ImageList_Destroy((HIMAGELIST)SendMessage(hWndClient,
TB_SETIMAGELIST,
diff --git a/modules/rosapps/applications/imagesoft/misc.c
b/modules/rosapps/applications/imagesoft/misc.c
index 4b72006152f..34a4793cb93 100644
--- a/modules/rosapps/applications/imagesoft/misc.c
+++ b/modules/rosapps/applications/imagesoft/misc.c
@@ -372,7 +372,8 @@ ToolbarInsertSpaceForControl(HWND hWndToolbar,
HIMAGELIST
-InitImageList(UINT NumImages, UINT StartResource)
+InitImageList(UINT StartResource,
+ UINT NumImages)
{
UINT EndResource = StartResource + NumImages - 1;
HBITMAP hBitmap;
@@ -390,7 +391,7 @@ InitImageList(UINT NumImages, UINT StartResource)
return NULL;
/* Add all icons to the image list */
- for (i = StartResource; i <= EndResource; i++)
+ for (i = StartResource; i <= EndResource && Ret != -1; i++)
{
hBitmap = LoadImage(hInstance,
MAKEINTRESOURCE(i),
@@ -409,9 +410,6 @@ InitImageList(UINT NumImages, UINT StartResource)
RGB(255, 255, 254));
DeleteObject(hBitmap);
-
- if (Ret == -1)
- break;
}
if (Ret == -1)
diff --git a/modules/rosapps/applications/imagesoft/misc.h
b/modules/rosapps/applications/imagesoft/misc.h
index 05d48307963..7a7d6cf15d8 100644
--- a/modules/rosapps/applications/imagesoft/misc.h
+++ b/modules/rosapps/applications/imagesoft/misc.h
@@ -40,5 +40,5 @@ BOOL ToolbarInsertSpaceForControl(HWND hWndToolbar,
INT iCmd,
BOOL HideVertical);
-HIMAGELIST InitImageList(UINT NumButtons,
- UINT StartResource);
+HIMAGELIST InitImageList(UINT StartResource,
+ UINT NumImages);