Commit 2e9c40d5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent f28824eb
...@@ -418,22 +418,48 @@ LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ...@@ -418,22 +418,48 @@ LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
switch (style) { switch (style) {
case SS_ICON: case SS_ICON:
{ {
const WCHAR *name = cs->lpszName;
HICON hIcon; HICON hIcon;
if (unicode || IS_INTRESOURCE(cs->lpszName))
hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style); if (!unicode)
{
const char *nameA = (const char *)name;
if (nameA && nameA[0] == '\xff')
name = MAKEINTRESOURCEW(MAKEWORD(nameA[1], nameA[2]));
}
else if (name && name[0] == 0xffff)
{
name = MAKEINTRESOURCEW(name[1]);
}
if (unicode || IS_INTRESOURCE(name))
hIcon = STATIC_LoadIconW(cs->hInstance, name, full_style);
else else
hIcon = STATIC_LoadIconA(cs->hInstance, (LPCSTR)cs->lpszName, full_style); hIcon = STATIC_LoadIconA(cs->hInstance, (const char *)name, full_style);
STATIC_SetIcon(hwnd, hIcon, full_style); STATIC_SetIcon(hwnd, hIcon, full_style);
} }
break; break;
case SS_BITMAP: case SS_BITMAP:
if ((ULONG_PTR)cs->hInstance >> 16) if ((ULONG_PTR)cs->hInstance >> 16)
{ {
const WCHAR *name = cs->lpszName;
HBITMAP hBitmap; HBITMAP hBitmap;
if (unicode || IS_INTRESOURCE(cs->lpszName))
hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName); if (!unicode)
{
const char *nameA = (const char *)name;
if (nameA && nameA[0] == '\xff')
name = MAKEINTRESOURCEW(MAKEWORD(nameA[1], nameA[2]));
}
else if (name && name[0] == 0xffff)
{
name = MAKEINTRESOURCEW(name[1]);
}
if (unicode || IS_INTRESOURCE(name))
hBitmap = LoadBitmapW(cs->hInstance, name);
else else
hBitmap = LoadBitmapA(cs->hInstance, (LPCSTR)cs->lpszName); hBitmap = LoadBitmapA(cs->hInstance, (const char *)name);
STATIC_SetBitmap(hwnd, hBitmap, full_style); STATIC_SetBitmap(hwnd, hBitmap, full_style);
} }
break; break;
......
...@@ -197,6 +197,24 @@ static void test_set_image(void) ...@@ -197,6 +197,24 @@ static void test_set_image(void)
DestroyWindow(hwnd); DestroyWindow(hwnd);
DeleteObject(image); DeleteObject(image);
hwnd = CreateWindowW(L"static", L"\uffff\x65", WS_VISIBLE|WS_CHILD|SS_BITMAP, 5, 5, 100, 100,
hMainWnd, (HMENU)CTRL_ID, GetModuleHandleW(NULL), 0);
bmp = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
ok(bmp != NULL, "got NULL\n");
test_image(bmp);
DestroyWindow(hwnd);
hwnd = CreateWindowA("static", "\xff\x65\0", WS_VISIBLE|WS_CHILD|SS_BITMAP, 5, 5, 100, 100,
hMainWnd, (HMENU)CTRL_ID, GetModuleHandleW(NULL), 0);
bmp = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
ok(bmp != NULL, "got NULL\n");
test_image(bmp);
DestroyWindow(hwnd);
} }
static void test_STM_SETIMAGE(void) static void test_STM_SETIMAGE(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment