user32: Add a test for BM_SETSTYLE, make it pass under Wine.
This commit is contained in:
parent
84fd1c84f8
commit
87418f0aaa
|
@ -75,6 +75,7 @@
|
|||
#include "wingdi.h"
|
||||
#include "wine/winuser16.h"
|
||||
#include "controls.h"
|
||||
#include "win.h"
|
||||
#include "user_private.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
|
@ -271,6 +272,13 @@ static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
|||
}
|
||||
if (btn_type >= MAX_BTN_TYPE)
|
||||
return -1; /* abort */
|
||||
|
||||
/* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
|
||||
if (btn_type == BS_USERBUTTON )
|
||||
{
|
||||
style = (style & ~0x0f) | BS_PUSHBUTTON;
|
||||
WIN_SetStyle( hWnd, style, 0x0f & ~style );
|
||||
}
|
||||
set_button_state( hWnd, BUTTON_UNCHECKED );
|
||||
return 0;
|
||||
|
||||
|
@ -458,11 +466,11 @@ static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
|||
if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
|
||||
btn_type = wParam & 0x0f;
|
||||
style = (style & ~0x0f) | btn_type;
|
||||
SetWindowLongW( hWnd, GWL_STYLE, style );
|
||||
WIN_SetStyle( hWnd, style, 0x0f & ~style );
|
||||
|
||||
/* Only redraw if lParam flag is set.*/
|
||||
if (lParam)
|
||||
paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
|
||||
InvalidateRect( hWnd, NULL, TRUE );
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1105,6 +1113,8 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
|
|||
if ((action == ODA_FOCUS) ||
|
||||
((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS)))
|
||||
DrawFocusRect( hDC, &rc );
|
||||
|
||||
BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5209,6 +5209,49 @@ static const struct message WmSetFontButtonSeq[] =
|
|||
{ WM_CTLCOLORBTN, sent|defwinproc },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmSetStyleButtonSeq[] =
|
||||
{
|
||||
{ BM_SETSTYLE, sent },
|
||||
{ WM_APP, sent|wparam|lparam, 0, 0 },
|
||||
{ WM_PAINT, sent },
|
||||
{ WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
|
||||
{ WM_ERASEBKGND, sent|defwinproc },
|
||||
{ WM_CTLCOLORBTN, sent|parent },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmSetStyleStaticSeq[] =
|
||||
{
|
||||
{ BM_SETSTYLE, sent },
|
||||
{ WM_APP, sent|wparam|lparam, 0, 0 },
|
||||
{ WM_PAINT, sent },
|
||||
{ WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
|
||||
{ WM_ERASEBKGND, sent|defwinproc },
|
||||
{ WM_CTLCOLORSTATIC, sent|parent },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmSetStyleUserSeq[] =
|
||||
{
|
||||
{ BM_SETSTYLE, sent },
|
||||
{ WM_APP, sent|wparam|lparam, 0, 0 },
|
||||
{ WM_PAINT, sent },
|
||||
{ WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
|
||||
{ WM_ERASEBKGND, sent|defwinproc },
|
||||
{ WM_CTLCOLORBTN, sent|parent },
|
||||
{ WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_PAINT) },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmSetStyleOwnerdrawSeq[] =
|
||||
{
|
||||
{ BM_SETSTYLE, sent },
|
||||
{ WM_APP, sent|wparam|lparam, 0, 0 },
|
||||
{ WM_PAINT, sent },
|
||||
{ WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
|
||||
{ WM_ERASEBKGND, sent|defwinproc },
|
||||
{ WM_CTLCOLORBTN, sent|parent },
|
||||
{ WM_CTLCOLORBTN, sent|parent },
|
||||
{ WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000010e4 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static WNDPROC old_button_proc;
|
||||
|
||||
|
@ -5268,29 +5311,30 @@ static void test_button_messages(void)
|
|||
DWORD dlg_code;
|
||||
const struct message *setfocus;
|
||||
const struct message *killfocus;
|
||||
const struct message *setstyle;
|
||||
} button[] = {
|
||||
{ BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq },
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq },
|
||||
{ BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq },
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq },
|
||||
{ BS_CHECKBOX, DLGC_BUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_AUTOCHECKBOX, DLGC_BUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_3STATE, DLGC_BUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_AUTO3STATE, DLGC_BUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_GROUPBOX, DLGC_STATIC,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq },
|
||||
WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleUserSeq },
|
||||
{ BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq },
|
||||
WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq },
|
||||
{ BS_OWNERDRAW, DLGC_BUTTON,
|
||||
WmSetFocusOwnerdrawSeq, WmKillFocusOwnerdrawSeq }
|
||||
WmSetFocusOwnerdrawSeq, WmKillFocusOwnerdrawSeq, WmSetStyleOwnerdrawSeq }
|
||||
};
|
||||
unsigned int i;
|
||||
HWND hwnd, parent;
|
||||
|
@ -5319,6 +5363,8 @@ static void test_button_messages(void)
|
|||
MSG msg;
|
||||
DWORD style;
|
||||
|
||||
trace("button style %08x\n", button[i].style);
|
||||
|
||||
hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_CHILD | BS_NOTIFY,
|
||||
0, 0, 50, 14, parent, (HMENU)ID_BUTTON, 0, NULL);
|
||||
ok(hwnd != 0, "Failed to create button window\n");
|
||||
|
@ -5327,9 +5373,9 @@ static void test_button_messages(void)
|
|||
style &= ~(WS_CHILD | BS_NOTIFY);
|
||||
/* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
|
||||
if (button[i].style == BS_USERBUTTON)
|
||||
todo_wine ok(style == BS_PUSHBUTTON, "expected style BS_PUSHBUTTON got %x\n", style);
|
||||
ok(style == BS_PUSHBUTTON, "expected style BS_PUSHBUTTON got %x\n", style);
|
||||
else
|
||||
ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style);
|
||||
ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style);
|
||||
|
||||
dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
|
||||
ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
|
||||
|
@ -5342,7 +5388,6 @@ static void test_button_messages(void)
|
|||
|
||||
log_all_parent_messages++;
|
||||
|
||||
trace("button style %08x\n", button[i].style);
|
||||
ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
|
||||
SetFocus(hwnd);
|
||||
SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
|
||||
|
@ -5354,9 +5399,20 @@ static void test_button_messages(void)
|
|||
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
|
||||
ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
|
||||
|
||||
ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
|
||||
|
||||
SendMessage(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
|
||||
SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
|
||||
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
|
||||
ok_sequence(button[i].setstyle, "BM_SETSTYLE on a button", FALSE);
|
||||
|
||||
style = GetWindowLongA(hwnd, GWL_STYLE);
|
||||
style &= ~(WS_VISIBLE | WS_CHILD | BS_NOTIFY);
|
||||
/* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
|
||||
ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style);
|
||||
|
||||
log_all_parent_messages--;
|
||||
|
||||
ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue