comctl32: Support passing bitmap and icon resource ID as a string when creating static control.

Follow Up of Merge request !693 by Jacek Caban. The pull request changed
properly the static control of user32, but didn't address the comctl32
static control.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53581
This commit is contained in:
Lorenzo Ferrillo 2022-09-03 19:25:45 +02:00 committed by Alexandre Julliard
parent 2b5a4b75be
commit c1db36686c
2 changed files with 37 additions and 2 deletions

View file

@ -437,6 +437,7 @@ static BOOL hasTextStyle( DWORD style )
static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{ {
const WCHAR *window_name;
LRESULT lResult = 0; LRESULT lResult = 0;
LONG full_style = GetWindowLongW( hwnd, GWL_STYLE ); LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
LONG style = full_style & SS_TYPEMASK; LONG style = full_style & SS_TYPEMASK;
@ -549,13 +550,18 @@ static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
SetWindowPos(hwnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(hwnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
} }
if (cs->lpszName && cs->lpszName[0] == 0xffff)
window_name = MAKEINTRESOURCEW(cs->lpszName[1]);
else
window_name = cs->lpszName;
switch (style) switch (style)
{ {
case SS_ICON: case SS_ICON:
{ {
HICON hIcon; HICON hIcon;
hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style); hIcon = STATIC_LoadIconW(cs->hInstance, window_name, full_style);
STATIC_SetIcon(hwnd, hIcon, full_style); STATIC_SetIcon(hwnd, hIcon, full_style);
} }
break; break;
@ -563,7 +569,7 @@ static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
if ((ULONG_PTR)cs->hInstance >> 16) if ((ULONG_PTR)cs->hInstance >> 16)
{ {
HBITMAP hBitmap; HBITMAP hBitmap;
hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName); hBitmap = LoadBitmapW(cs->hInstance, window_name);
STATIC_SetBitmap(hwnd, hBitmap, full_style); STATIC_SetBitmap(hwnd, hBitmap, full_style);
} }
break; break;

View file

@ -216,6 +216,8 @@ static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult, BOOL is_alph
static void test_set_image(void) static void test_set_image(void)
{ {
char resource[4];
WCHAR resource_unicode[3];
HWND hwnd = create_static(SS_BITMAP); HWND hwnd = create_static(SS_BITMAP);
HBITMAP bmp1, bmp2, image; HBITMAP bmp1, bmp2, image;
@ -270,6 +272,33 @@ static void test_set_image(void)
test_image(image, TRUE, FALSE, FALSE); test_image(image, TRUE, FALSE, FALSE);
resource[0] = '\xff';
resource[1] = PtrToUlong(MAKEINTRESOURCEW(IDB_BITMAP_1x1_32BPP));
resource[2] = PtrToUlong(MAKEINTRESOURCEW(IDB_BITMAP_1x1_32BPP)) >> 8;
resource[3] = 0;
resource_unicode[0] = 0xffff;
resource_unicode[1] = PtrToUlong(MAKEINTRESOURCEW(IDB_BITMAP_1x1_32BPP));
resource_unicode[2] = 0;
hwnd = CreateWindowW(L"Static", resource_unicode, WS_VISIBLE|WS_CHILD|SS_BITMAP, 5, 5, 100, 100,
hMainWnd, (HMENU)CTRL_ID, GetModuleHandleW(NULL), 0);
bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
ok(bmp1 != NULL, "got NULL\n");
ok(bmp1 != image, "bmp == image\n");
test_image(bmp1, TRUE, TRUE, TRUE);
DestroyWindow(hwnd);
hwnd = CreateWindowA("Static", resource, WS_VISIBLE|WS_CHILD|SS_BITMAP, 5, 5, 100, 100,
hMainWnd, (HMENU)CTRL_ID, GetModuleHandleW(NULL), 0);
bmp1 = (HBITMAP)SendMessageA(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
ok(bmp1 != NULL, "got NULL\n");
ok(bmp1 != image, "bmp == image\n");
test_image(bmp1, TRUE, TRUE, TRUE);
DestroyWindow(hwnd);
DeleteObject(image); DeleteObject(image);
} }