comctl32/button: Implement BCM_{GET,SET}IMAGELIST message.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3c8ff605a6
commit
0d4940b732
|
@ -29,9 +29,7 @@
|
|||
* - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
|
||||
* - WM_SYSKEYUP
|
||||
* - BCM_GETIDEALSIZE
|
||||
* - BCM_GETIMAGELIST
|
||||
* - BCM_GETTEXTMARGIN
|
||||
* - BCM_SETIMAGELIST
|
||||
* - BCM_SETTEXTMARGIN
|
||||
*
|
||||
* Notifications
|
||||
|
@ -45,12 +43,9 @@
|
|||
* - NM_CUSTOMDRAW
|
||||
*
|
||||
* Structures/Macros/Definitions
|
||||
* - BUTTON_IMAGELIST
|
||||
* - NMBCHOTITEM
|
||||
* - Button_GetIdealSize
|
||||
* - Button_GetImageList
|
||||
* - Button_GetTextMargin
|
||||
* - Button_SetImageList
|
||||
* - Button_SetTextMargin
|
||||
*/
|
||||
|
||||
|
@ -97,6 +92,7 @@ typedef struct _BUTTON_INFO
|
|||
WCHAR *note;
|
||||
INT note_length;
|
||||
DWORD image_type; /* IMAGE_BITMAP or IMAGE_ICON */
|
||||
BUTTON_IMAGELIST imagelist;
|
||||
union
|
||||
{
|
||||
HICON icon;
|
||||
|
@ -728,6 +724,26 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
|||
case BM_GETIMAGE:
|
||||
return (LRESULT)infoPtr->u.image;
|
||||
|
||||
case BCM_SETIMAGELIST:
|
||||
{
|
||||
BUTTON_IMAGELIST *imagelist = (BUTTON_IMAGELIST *)lParam;
|
||||
|
||||
if (!imagelist) return FALSE;
|
||||
|
||||
infoPtr->imagelist = *imagelist;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case BCM_GETIMAGELIST:
|
||||
{
|
||||
BUTTON_IMAGELIST *imagelist = (BUTTON_IMAGELIST *)lParam;
|
||||
|
||||
if (!imagelist) return FALSE;
|
||||
|
||||
*imagelist = infoPtr->imagelist;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case BM_GETCHECK:
|
||||
return infoPtr->state & 3;
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
|
||||
static BOOL (WINAPI *pRemoveWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR);
|
||||
static LRESULT (WINAPI *pDefSubclassProc)(HWND, UINT, WPARAM, LPARAM);
|
||||
static HIMAGELIST(WINAPI *pImageList_Create)(int, int, UINT, int, int);
|
||||
static int(WINAPI *pImageList_Add)(HIMAGELIST, HBITMAP, HBITMAP);
|
||||
|
||||
/****************** button message test *************************/
|
||||
#define ID_BUTTON 0x000e
|
||||
|
@ -77,6 +79,11 @@ static void init_functions(void)
|
|||
MAKEFUNC_ORD(RemoveWindowSubclass, 412);
|
||||
MAKEFUNC_ORD(DefSubclassProc, 413);
|
||||
#undef MAKEFUNC_ORD
|
||||
|
||||
#define X(f) p##f = (void *)GetProcAddress(hmod, #f);
|
||||
X(ImageList_Create);
|
||||
X(ImageList_Add);
|
||||
#undef X
|
||||
}
|
||||
|
||||
/* try to make sure pending X events have been processed before continuing */
|
||||
|
@ -1270,6 +1277,84 @@ static void test_button_data(void)
|
|||
DestroyWindow(parent);
|
||||
}
|
||||
|
||||
static void test_get_set_imagelist(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
HIMAGELIST himl;
|
||||
BUTTON_IMAGELIST biml = {0};
|
||||
HDC hdc;
|
||||
HBITMAP hbmp;
|
||||
INT width = 16;
|
||||
INT height = 16;
|
||||
INT index;
|
||||
DWORD type;
|
||||
BOOL ret;
|
||||
|
||||
hdc = GetDC(0);
|
||||
hbmp = CreateCompatibleBitmap(hdc, width, height);
|
||||
ok(hbmp != NULL, "Expect hbmp not null\n");
|
||||
|
||||
himl = pImageList_Create(width, height, ILC_COLOR, 1, 0);
|
||||
ok(himl != NULL, "Expect himl not null\n");
|
||||
index = pImageList_Add(himl, hbmp, NULL);
|
||||
ok(index == 0, "Expect index == 0\n");
|
||||
DeleteObject(hbmp);
|
||||
ReleaseDC(0, hdc);
|
||||
|
||||
for (type = BS_PUSHBUTTON; type <= BS_DEFCOMMANDLINK; type++)
|
||||
{
|
||||
hwnd = create_button(type, NULL);
|
||||
ok(hwnd != NULL, "Expect hwnd not null\n");
|
||||
|
||||
/* Get imagelist when imagelist is unset yet */
|
||||
ret = SendMessageA(hwnd, BCM_GETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_GETIMAGELIST return true\n");
|
||||
ok(biml.himl == 0 && IsRectEmpty(&biml.margin) && biml.uAlign == 0,
|
||||
"Expect BUTTON_IMAGELIST is empty\n");
|
||||
|
||||
/* Set imagelist with himl null */
|
||||
biml.himl = 0;
|
||||
biml.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
|
||||
ret = SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret || broken(!ret), /* xp or 2003 */
|
||||
"Expect BCM_SETIMAGELIST return true\n");
|
||||
|
||||
/* Set imagelist with uAlign invalid */
|
||||
biml.himl = himl;
|
||||
biml.uAlign = -1;
|
||||
ret = SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_SETIMAGELIST return true\n");
|
||||
|
||||
/* Successful get and set imagelist */
|
||||
biml.himl = himl;
|
||||
biml.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
|
||||
ret = SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_SETIMAGELIST return true\n");
|
||||
ret = SendMessageA(hwnd, BCM_GETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_GETIMAGELIST return true\n");
|
||||
ok(biml.himl == himl, "Expect himl to be same\n");
|
||||
ok(biml.uAlign == BUTTON_IMAGELIST_ALIGN_CENTER, "Expect uAlign to be %x\n",
|
||||
BUTTON_IMAGELIST_ALIGN_CENTER);
|
||||
|
||||
/* BCM_SETIMAGELIST null pointer handling */
|
||||
ret = SendMessageA(hwnd, BCM_SETIMAGELIST, 0, 0);
|
||||
ok(!ret, "Expect BCM_SETIMAGELIST return false\n");
|
||||
ret = SendMessageA(hwnd, BCM_GETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_GETIMAGELIST return true\n");
|
||||
ok(biml.himl == himl, "Expect himl to be same\n");
|
||||
|
||||
/* BCM_GETIMAGELIST null pointer handling */
|
||||
biml.himl = himl;
|
||||
biml.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
|
||||
ret = SendMessageA(hwnd, BCM_SETIMAGELIST, 0, (LPARAM)&biml);
|
||||
ok(ret, "Expect BCM_SETIMAGELIST return true\n");
|
||||
ret = SendMessageA(hwnd, BCM_GETIMAGELIST, 0, 0);
|
||||
ok(!ret, "Expect BCM_GETIMAGELIST return false\n");
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(button)
|
||||
{
|
||||
ULONG_PTR ctx_cookie;
|
||||
|
@ -1288,6 +1373,7 @@ START_TEST(button)
|
|||
test_note();
|
||||
test_button_data();
|
||||
test_bm_get_set_image();
|
||||
test_get_set_imagelist();
|
||||
|
||||
unload_v6_module(ctx_cookie, hCtx);
|
||||
}
|
||||
|
|
|
@ -1100,6 +1100,10 @@ typedef struct tagNMBCHOTITEM
|
|||
(BOOL)SNDMSG(button, BCM_GETNOTE, (WPARAM)(size), (LPARAM)(buffer))
|
||||
#define Button_GetNoteLength(button) \
|
||||
(LRESULT)SNDMSG(button, BCM_GETNOTELENGTH, 0, 0)
|
||||
#define Button_GetImageList(button, image_list) \
|
||||
(BOOL)SNDMSG(button, BCM_GETIMAGELIST, 0, (LPARAM)(image_list))
|
||||
#define Button_SetImageList(button, image_list) \
|
||||
(BOOL)SNDMSG(button, BCM_SETIMAGELIST, 0, (LPARAM)(image_list))
|
||||
|
||||
/* Toolbar */
|
||||
|
||||
|
|
Loading…
Reference in New Issue