comctl32/button: Implement BCM_{GET,SET}TEXTMARGIN 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:
Zhiyi Zhang 2018-04-04 10:50:44 +08:00 committed by Alexandre Julliard
parent 0d4940b732
commit 1c6e71d62a
3 changed files with 74 additions and 4 deletions

View File

@ -29,8 +29,6 @@
* - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
* - WM_SYSKEYUP
* - BCM_GETIDEALSIZE
* - BCM_GETTEXTMARGIN
* - BCM_SETTEXTMARGIN
*
* Notifications
* - BCN_HOTITEMCHANGE
@ -45,8 +43,6 @@
* Structures/Macros/Definitions
* - NMBCHOTITEM
* - Button_GetIdealSize
* - Button_GetTextMargin
* - Button_SetTextMargin
*/
#include <stdarg.h>
@ -93,6 +89,7 @@ typedef struct _BUTTON_INFO
INT note_length;
DWORD image_type; /* IMAGE_BITMAP or IMAGE_ICON */
BUTTON_IMAGELIST imagelist;
RECT text_margin;
union
{
HICON icon;
@ -785,6 +782,26 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
}
break;
case BCM_SETTEXTMARGIN:
{
RECT *text_margin = (RECT *)lParam;
if (!text_margin) return FALSE;
infoPtr->text_margin = *text_margin;
return TRUE;
}
case BCM_GETTEXTMARGIN:
{
RECT *text_margin = (RECT *)lParam;
if (!text_margin) return FALSE;
*text_margin = infoPtr->text_margin;
return TRUE;
}
case WM_NCHITTEST:
if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
/* fall through */

View File

@ -1355,6 +1355,54 @@ static void test_get_set_imagelist(void)
}
}
static void test_get_set_textmargin(void)
{
HWND hwnd;
RECT margin_in;
RECT margin_out;
BOOL ret;
DWORD type;
margin_in.top = 1;
margin_in.left = 2;
margin_in.right = 3;
margin_in.bottom = 4;
for (type = BS_PUSHBUTTON; type <= BS_DEFCOMMANDLINK; type++)
{
hwnd = create_button(type, NULL);
ok(hwnd != NULL, "Expect hwnd not null\n");
/* Get text margin when it is unset */
ret = SendMessageA(hwnd, BCM_GETTEXTMARGIN, 0, (LPARAM)&margin_out);
ok(ret, "Expect ret to be true\n");
ok(IsRectEmpty(&margin_out), "Expect margin empty\n");
/* Successful get and set text margin */
ret = SendMessageA(hwnd, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin_in);
ok(ret, "Expect ret to be true\n");
SetRectEmpty(&margin_out);
ret = SendMessageA(hwnd, BCM_GETTEXTMARGIN, 0, (LPARAM)&margin_out);
ok(ret, "Expect ret to be true\n");
ok(EqualRect(&margin_in, &margin_out), "Expect margins to be equal\n");
/* BCM_SETTEXTMARGIN null pointer handling */
ret = SendMessageA(hwnd, BCM_SETTEXTMARGIN, 0, 0);
ok(!ret, "Expect ret to be false\n");
SetRectEmpty(&margin_out);
ret = SendMessageA(hwnd, BCM_GETTEXTMARGIN, 0, (LPARAM)&margin_out);
ok(ret, "Expect ret to be true\n");
ok(EqualRect(&margin_in, &margin_out), "Expect margins to be equal\n");
/* BCM_GETTEXTMARGIN null pointer handling */
ret = SendMessageA(hwnd, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin_in);
ok(ret, "Expect ret to be true\n");
ret = SendMessageA(hwnd, BCM_GETTEXTMARGIN, 0, 0);
ok(!ret, "Expect ret to be true\n");
DestroyWindow(hwnd);
}
}
START_TEST(button)
{
ULONG_PTR ctx_cookie;
@ -1374,6 +1422,7 @@ START_TEST(button)
test_button_data();
test_bm_get_set_image();
test_get_set_imagelist();
test_get_set_textmargin();
unload_v6_module(ctx_cookie, hCtx);
}

View File

@ -1104,6 +1104,10 @@ typedef struct tagNMBCHOTITEM
(BOOL)SNDMSG(button, BCM_GETIMAGELIST, 0, (LPARAM)(image_list))
#define Button_SetImageList(button, image_list) \
(BOOL)SNDMSG(button, BCM_SETIMAGELIST, 0, (LPARAM)(image_list))
#define Button_GetTextMargin(button, margin) \
(BOOL)SNDMSG(button, BCM_GETTEXTMARGIN, 0, (LPARAM)(margin))
#define Button_SetTextMargin(button, margin) \
(BOOL)SNDMSG(button, BCM_SETTEXTMARGIN, 0, (LPARAM)(margin))
/* Toolbar */