Commit 7699d8e4 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32/tests: Add BM_SETIMAGE style check tests.

parent 06d2ad29
......@@ -6502,6 +6502,121 @@ static void test_button_messages(void)
DestroyWindow(parent);
}
static void test_button_bm_get_set_image(void)
{
HWND hwnd;
HDC hdc;
HBITMAP hbmp1x1;
HBITMAP hbmp2x2;
HBITMAP hmask2x2;
ICONINFO icon_info2x2;
HICON hicon2x2;
HBITMAP hbmp;
HICON hicon;
ICONINFO icon_info;
BITMAP bm;
DWORD default_style = BS_PUSHBUTTON | WS_TABSTOP | WS_POPUP | WS_VISIBLE;
LRESULT ret;
hdc = GetDC(0);
hbmp1x1 = CreateCompatibleBitmap(hdc, 1, 1);
hbmp2x2 = CreateCompatibleBitmap(hdc, 2, 2);
ZeroMemory(&bm, sizeof(bm));
ok(GetObjectW(hbmp1x1, sizeof(bm), &bm), "Expect GetObjectW() success\n");
ok(bm.bmWidth == 1 && bm.bmHeight == 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1,
bm.bmWidth, bm.bmHeight);
ZeroMemory(&bm, sizeof(bm));
ok(GetObjectW(hbmp2x2, sizeof(bm), &bm), "Expect GetObjectW() success\n");
ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
bm.bmWidth, bm.bmHeight);
hmask2x2 = CreateCompatibleBitmap(hdc, 2, 2);
ZeroMemory(&icon_info2x2, sizeof(icon_info2x2));
icon_info2x2.fIcon = TRUE;
icon_info2x2.hbmMask = hmask2x2;
icon_info2x2.hbmColor = hbmp2x2;
hicon2x2 = CreateIconIndirect(&icon_info2x2);
ZeroMemory(&icon_info, sizeof(icon_info));
ok(GetIconInfo(hicon2x2, &icon_info), "Expect GetIconInfo() success\n");
ZeroMemory(&bm, sizeof(bm));
ok(GetObjectW(icon_info.hbmColor, sizeof(bm), &bm), "Expect GetObjectW() success\n");
ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
bm.bmWidth, bm.bmHeight);
DeleteObject(icon_info.hbmColor);
DeleteObject(icon_info.hbmMask);
/* Set bitmap with BS_BITMAP */
hwnd = CreateWindowA("Button", "test", default_style | BS_BITMAP, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1);
hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0);
ok(hbmp != 0, "Expect hbmp not 0\n");
ZeroMemory(&bm, sizeof(bm));
ok(GetObjectW(hbmp, sizeof(bm), &bm), "Expect GetObjectW() success\n");
ok(bm.bmWidth == 1 && bm.bmHeight == 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1,
bm.bmWidth, bm.bmHeight);
DestroyWindow(hwnd);
/* Set bitmap without BS_BITMAP */
hwnd = CreateWindowA("Button", "test", default_style, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd not NULL\n");
ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1);
ok(ret == 0, "Expect ret to be 0\n");
hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0);
ok(hbmp == NULL, "Expect hbmp to be NULL\n");
DestroyWindow(hwnd);
/* Set icon with BS_ICON */
hwnd = CreateWindowA("Button", "test", default_style | BS_ICON, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd not NULL\n");
SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2);
hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0);
ok(hicon != NULL, "Expect hicon not NULL\n");
ZeroMemory(&icon_info, sizeof(icon_info));
ok(GetIconInfo(hicon, &icon_info), "Expect GetIconInfo() success\n");
ZeroMemory(&bm, sizeof(bm));
ok(GetObjectW(icon_info.hbmColor, sizeof(bm), &bm), "Expect GetObjectW() success\n");
ok(bm.bmWidth == 2 && bm.bmHeight == 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
bm.bmWidth, bm.bmHeight);
DeleteObject(icon_info.hbmColor);
DeleteObject(icon_info.hbmMask);
DestroyWindow(hwnd);
/* Set icon without BS_ICON */
hwnd = CreateWindowA("Button", "test", default_style, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd not NULL\n");
ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2);
ok(ret == 0, "Expect ret to be 0\n");
hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0);
ok(hicon == NULL, "Expect hicon to be NULL\n");
DestroyWindow(hwnd);
/* Set icon with BS_BITMAP */
hwnd = CreateWindowA("Button", "test", default_style | BS_BITMAP, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd to be not NULL\n");
ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hicon2x2);
ok(ret == 0, "Expect ret to be 0\n");
hicon = (HICON)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_ICON, 0);
ok(hicon == NULL, "Expect hicon to be NULL\n");
DestroyWindow(hwnd);
/* Set bitmap with BS_ICON */
hwnd = CreateWindowA("Button", "test", default_style | BS_ICON, 0, 0, 100, 100, 0, 0, 0, 0);
ok(hwnd != NULL, "Expect hwnd to be not NULL\n");
ret = SendMessageA(hwnd, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbmp1x1);
ok(ret == 0, "Expect ret to be 0\n");
hbmp = (HBITMAP)SendMessageA(hwnd, BM_GETIMAGE, (WPARAM)IMAGE_BITMAP, 0);
ok(hbmp == NULL, "Expect hbmp to be NULL\n");
DestroyWindow(hwnd);
DestroyIcon(hicon2x2);
DeleteObject(hmask2x2);
DeleteObject(hbmp2x2);
DeleteObject(hbmp1x1);
ReleaseDC(0, hdc);
}
/****************** static message test *************************/
static const struct message WmSetFontStaticSeq2[] =
{
......@@ -16721,6 +16836,7 @@ START_TEST(msg)
invisible_parent_tests();
test_mdi_messages();
test_button_messages();
test_button_bm_get_set_image();
test_static_messages();
test_listbox_messages();
test_combobox_messages();
......
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