[USER32_WINETEST] Sync with Wine Staging 1.9.18. One skipped part of clipboard.c is documented in CORE-11953

svn path=/trunk/; revision=72616
This commit is contained in:
Amine Khaldi 2016-09-07 23:24:48 +00:00
parent a38f07f3e8
commit bca9ea7b61
8 changed files with 1668 additions and 91 deletions

File diff suppressed because it is too large Load diff

View file

@ -2511,12 +2511,6 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV
ok(!lstrcmpW((WCHAR*)buffer, cmd_w),
"Expected %s, msg_index=%d\n", wine_dbgstr_w(cmd_w), msg_index);
}
else if (unicode_client)
{
ok(size == size_w_to_a, "Wrong size %d/%d, msg_index=%d\n", size, size_w_to_a, msg_index);
ok(!lstrcmpA((CHAR*)buffer, test_cmd_w_to_a), "Expected %s, got %s, msg_index=%d\n",
test_cmd_w_to_a, buffer, msg_index);
}
else
{
ok(size == size_w_to_a, "Wrong size %d/%d, msg_index=%d\n",

View file

@ -733,8 +733,23 @@ static void test_WM_NEXTDLGCTL(void)
DestroyWindow(g_hwndTestDlg);
}
static LRESULT CALLBACK hook_proc(INT code, WPARAM wParam, LPARAM lParam)
{
ok(0, "unexpected hook called, code %d\n", code);
return CallNextHookEx(NULL, code, wParam, lParam);
}
static BOOL g_MSGF_DIALOGBOX;
static LRESULT CALLBACK hook_proc2(INT code, WPARAM wParam, LPARAM lParam)
{
ok(code == MSGF_DIALOGBOX, "unexpected hook called, code %d\n", code);
g_MSGF_DIALOGBOX = code == MSGF_DIALOGBOX;
return CallNextHookEx(NULL, code, wParam, lParam);
}
static void test_IsDialogMessage(void)
{
HHOOK hook;
MSG msg;
g_hwndMain = CreateWindowA("IsDialogMessageWindowClass", "IsDialogMessageWindowClass",
@ -746,11 +761,34 @@ static void test_IsDialogMessage(void)
assert (g_hwndButton1);
assert (g_hwndButtonCancel);
if (0)
{
/* crashes on Windows */
IsDialogMessageA(NULL, NULL);
IsDialogMessageA(g_hwndMain, NULL);
}
/* The focus should initially be nowhere. The first TAB should take it
* to the first button. The second TAB should take it to the Cancel
* button.
*/
/* valid window, invalid message window */
hook = SetWindowsHookExA(WH_MSGFILTER, hook_proc2, NULL, GetCurrentThreadId());
FormTabMsg (&msg, (HWND)0xbeefbeef);
ok (!IsDialogMessageA(g_hwndMain, &msg), "expected failure\n");
ok(g_MSGF_DIALOGBOX, "hook wasn't called\n");
g_MSGF_DIALOGBOX = FALSE;
UnhookWindowsHookEx(hook);
hook = SetWindowsHookExA(WH_MSGFILTER, hook_proc, NULL, GetCurrentThreadId());
FormTabMsg (&msg, g_hwndMain);
ok (!IsDialogMessageA(NULL, &msg), "expected failure\n");
ok (!IsDialogMessageA((HWND)0xbeefbeef, &msg), "expected failure\n");
UnhookWindowsHookEx(hook);
ok (IsDialogMessageA(g_hwndMain, &msg), "Did not handle first TAB\n");
ok ((GetFocus() == g_hwndButton1), "Focus did not move to first button\n");
FormTabMsg (&msg, g_hwndButton1);
@ -760,6 +798,18 @@ static void test_IsDialogMessage(void)
FormEnterMsg (&msg, g_hwndButtonCancel);
ok (IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n");
ok (g_terminated, "ENTER did not terminate\n");
/* matching but invalid window handles, NULL */
hook = SetWindowsHookExA(WH_MSGFILTER, hook_proc, NULL, GetCurrentThreadId());
FormTabMsg (&msg, NULL);
ok (!IsDialogMessageA(msg.hwnd, &msg), "expected failure\n");
/* matching but invalid window handles, not NULL */
FormTabMsg (&msg, (HWND)0xbeefbeef);
ok (!IsDialogMessageA(msg.hwnd, &msg), "expected failure\n");
UnhookWindowsHookEx(hook);
}

View file

@ -1421,14 +1421,118 @@ static void test_edit_control_scroll(void)
DestroyWindow (hwEdit);
}
static void test_margins_usefontinfo(UINT charset)
{
HWND hwnd;
HDC hdc;
SIZE size;
BOOL cjk = FALSE;
LOGFONTA lf;
HFONT hfont;
RECT rect;
INT margins, threshold, expect, empty_expect, small_expect;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -11;
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = charset;
strcpy(lf.lfFaceName, "Tahoma");
hfont = CreateFontIndirectA(&lf);
ok(hfont != NULL, "got %p\n", hfont);
/* Big window rectangle */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
hdc = GetDC(hwnd);
hfont = SelectObject(hdc, hfont);
size.cx = GdiGetCharDimensions( hdc, NULL, &size.cy );
expect = MAKELONG(size.cx / 2, size.cx / 2);
small_expect = 0;
empty_expect = size.cx >= 28 ? small_expect : expect;
charset = GetTextCharset(hdc);
switch (charset)
{
case SHIFTJIS_CHARSET:
case HANGUL_CHARSET:
case GB2312_CHARSET:
case CHINESEBIG5_CHARSET:
cjk = TRUE;
}
hfont = SelectObject(hdc, hfont);
ReleaseDC(hwnd, hdc);
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
if (!cjk)
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
else
{
ok(HIWORD(margins) > 0 && LOWORD(margins) > 0, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
expect = empty_expect = small_expect = margins;
}
DestroyWindow(hwnd);
threshold = (size.cx / 2 + size.cx) * 2;
/* Size below which non-cjk margins are zero */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold - 1, 100, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == small_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
/* Size at which non-cjk margins become non-zero */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold, 100, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
/* Empty rect */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
ok(IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == empty_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
DeleteObject(hfont);
}
static void test_margins(void)
{
HWND hwEdit;
RECT old_rect, new_rect;
INT old_right_margin;
DWORD old_margins, new_margins;
LOGFONTA lf;
HFONT hfont;
hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
@ -1487,45 +1591,16 @@ static void test_margins(void)
DestroyWindow (hwEdit);
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -11;
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
strcpy(lf.lfFaceName, "Tahoma");
test_margins_usefontinfo(ANSI_CHARSET);
test_margins_usefontinfo(EASTEUROPE_CHARSET);
hfont = CreateFontIndirectA(&lf);
ok(hfont != NULL, "got %p\n", hfont);
test_margins_usefontinfo(SHIFTJIS_CHARSET);
test_margins_usefontinfo(HANGUL_CHARSET);
test_margins_usefontinfo(CHINESEBIG5_CHARSET);
/* Don't test JOHAB_CHARSET. Treated as CJK by Win 8,
but not by < Win 8 and Win 10. */
/* Empty window rectangle */
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
ok(hwEdit != NULL, "got %p\n", hwEdit);
GetClientRect(hwEdit, &old_rect);
ok(IsRectEmpty(&old_rect), "got rect %s\n", wine_dbgstr_rect(&old_rect));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %x\n", old_margins);
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(HIWORD(old_margins) > 0 && LOWORD(old_margins) > 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
DestroyWindow(hwEdit);
/* Size is not enough to display a text, but not empty */
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 2, 2, NULL, NULL, NULL, NULL);
ok(hwEdit != NULL, "got %p\n", hwEdit);
GetClientRect(hwEdit, &old_rect);
ok(!IsRectEmpty(&old_rect), "got rect %s\n", wine_dbgstr_rect(&old_rect));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %x\n", old_margins);
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
DeleteObject(hfont);
DestroyWindow(hwEdit);
test_margins_usefontinfo(DEFAULT_CHARSET);
}
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)

View file

@ -184,7 +184,7 @@ static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
(VKey != VK_MENU)) /* <ALT>-down...<something else>-up */
message = WM_SYSKEYUP;
TrackSysKey = 0; /* FIXME */
TrackSysKey = 0;
}
InputKeyStateTable[VKey] &= ~0x80;
flags |= KF_REPEAT | KF_UP;
@ -1767,10 +1767,8 @@ static void test_keyboard_layout_name(void)
BOOL ret;
char klid[KL_NAMELENGTH];
if (0) /* crashes on native system */
{
ret = GetKeyboardLayoutNameA(NULL);
}
if (0) /* crashes on native system */
ret = GetKeyboardLayoutNameA(NULL);
SetLastError(0xdeadbeef);
ret = GetKeyboardLayoutNameW(NULL);

View file

@ -3972,15 +3972,13 @@ static void test_AppendMenu(void)
mii.wID = 206;
ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
ok(ret, "InsertMenuItem failed\n");
if (0) /* FIXME: uncomment once Wine is fixed */
{
if (0) /* FIXME: uncomment once Wine is fixed */ {
check_menu_items(hmenu, 206, MF_SEPARATOR, MFS_GRAYED);
}
mii.wID = 207;
ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
ok(ret, "SetMenuItemInfo failed\n");
if (0) /* FIXME: uncomment once Wine is fixed */
{
if (0) /* FIXME: uncomment once Wine is fixed */ {
check_menu_items(hmenu, 207, MF_SEPARATOR, MFS_GRAYED);
}
DestroyMenu(hmenu);

View file

@ -8252,6 +8252,12 @@ static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
return 0;
}
if (message == WM_CONTEXTMENU)
{
/* don't create context menu */
return 0;
}
defwndproc_counter++;
ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
: DefWindowProcA(hwnd, message, wParam, lParam);
@ -13968,13 +13974,46 @@ static void test_paintingloop(void)
DestroyWindow(hwnd);
}
static const struct message NCRBUTTONDOWNSeq[] =
{
{ EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
{ EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
{ WM_CAPTURECHANGED, sent },
{ WM_CONTEXTMENU, sent, /*hwnd*/0, -1 },
{ 0 }
};
static void test_defwinproc(void)
{
HWND hwnd;
MSG msg;
BOOL gotwmquit = FALSE;
hwnd = CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP, 0,0,0,0,0,0,0, NULL);
POINT pos;
RECT rect;
INT x, y;
LRESULT res;
hwnd = CreateWindowExA(0, "TestWindowClass", "test_defwndproc",
WS_VISIBLE | WS_CAPTION | WS_OVERLAPPEDWINDOW, 0,0,500,100,0,0,0, NULL);
assert(hwnd);
flush_events();
GetCursorPos(&pos);
GetWindowRect(hwnd, &rect);
x = (rect.left+rect.right) / 2;
y = rect.top + GetSystemMetrics(SM_CYFRAME) + 1;
SetCursorPos(x, y);
flush_events();
res = DefWindowProcA( hwnd, WM_NCHITTEST, 0, MAKELPARAM(x, y));
ok(res == HTCAPTION, "WM_NCHITTEST returned %ld\n", res);
flush_sequence();
PostMessageA( hwnd, WM_RBUTTONUP, 0, 0);
DefWindowProcA( hwnd, WM_NCRBUTTONDOWN, HTCAPTION, MAKELPARAM(x, y));
ok_sequence(NCRBUTTONDOWNSeq, "WM_NCRBUTTONDOWN on caption", FALSE);
SetCursorPos(pos.x, pos.y);
DefWindowProcA( hwnd, WM_ENDSESSION, 1, 0);
while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) {
if( msg.message == WM_QUIT) gotwmquit = TRUE;
@ -14108,7 +14147,7 @@ static void test_clipboard_viewers(void)
expect_HWND(hWnd1, GetClipboardViewer());
ChangeClipboardChain(NULL, hWnd2);
ok_sequence(WmEmptySeq, "change chain (viewer=1, remove=NULL, next=2)", TRUE);
ok_sequence(WmEmptySeq, "change chain (viewer=1, remove=NULL, next=2)", FALSE);
expect_HWND(hWnd1, GetClipboardViewer());
/* Actually change clipboard viewer with ChangeClipboardChain. */
@ -15868,6 +15907,98 @@ todo_wine_if (thread_n == 2)
flush_sequence();
}
static LRESULT CALLBACK insendmessage_wnd_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
DWORD flags = InSendMessageEx( NULL );
BOOL ret;
switch (msg)
{
case WM_USER:
ok( flags == ISMEX_SEND, "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
ret = ReplyMessage( msg );
ok( ret, "ReplyMessage failed err %u\n", GetLastError() );
flags = InSendMessageEx( NULL );
ok( flags == (ISMEX_SEND | ISMEX_REPLIED), "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
break;
case WM_USER + 1:
ok( flags == ISMEX_NOTIFY, "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
ret = ReplyMessage( msg );
ok( ret, "ReplyMessage failed err %u\n", GetLastError() );
flags = InSendMessageEx( NULL );
ok( flags == ISMEX_NOTIFY, "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
break;
case WM_USER + 2:
ok( flags == ISMEX_CALLBACK, "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
ret = ReplyMessage( msg );
ok( ret, "ReplyMessage failed err %u\n", GetLastError() );
flags = InSendMessageEx( NULL );
ok( flags == (ISMEX_CALLBACK | ISMEX_REPLIED) || flags == ISMEX_SEND, "wrong flags %x\n", flags );
ok( InSendMessage(), "InSendMessage returned false\n" );
break;
case WM_USER + 3:
ok( flags == ISMEX_NOSEND, "wrong flags %x\n", flags );
ok( !InSendMessage(), "InSendMessage returned true\n" );
ret = ReplyMessage( msg );
ok( !ret, "ReplyMessage succeeded\n" );
break;
}
return DefWindowProcA( hwnd, msg, wp, lp );
}
static void CALLBACK msg_callback( HWND hwnd, UINT msg, ULONG_PTR arg, LRESULT result )
{
ok( msg == WM_USER + 2, "wrong msg %x\n", msg );
ok( result == WM_USER + 2, "wrong result %lx\n", result );
}
static DWORD WINAPI send_message_thread( void *arg )
{
HWND win = arg;
SendMessageA( win, WM_USER, 0, 0 );
SendNotifyMessageA( win, WM_USER + 1, 0, 0 );
SendMessageCallbackA( win, WM_USER + 2, 0, 0, msg_callback, 0 );
PostMessageA( win, WM_USER + 3, 0, 0 );
PostMessageA( win, WM_QUIT, 0, 0 );
return 0;
}
static void test_InSendMessage(void)
{
WNDCLASSA cls;
HWND win;
MSG msg;
HANDLE thread;
DWORD tid;
memset(&cls, 0, sizeof(cls));
cls.lpfnWndProc = insendmessage_wnd_proc;
cls.hInstance = GetModuleHandleA(NULL);
cls.lpszClassName = "InSendMessage_test";
RegisterClassA(&cls);
win = CreateWindowA( "InSendMessage_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0 );
ok( win != NULL, "CreateWindow failed: %d\n", GetLastError() );
thread = CreateThread( NULL, 0, send_message_thread, win, 0, &tid );
ok( thread != NULL, "CreateThread failed: %d\n", GetLastError() );
while (GetMessageA(&msg, NULL, 0, 0)) DispatchMessageA( &msg );
ok( WaitForSingleObject( thread, 30000 ) == WAIT_OBJECT_0, "WaitForSingleObject failed\n" );
CloseHandle( thread );
DestroyWindow( win );
UnregisterClassA( "InSendMessage_test", GetModuleHandleA(NULL) );
}
static const struct message DoubleSetCaptureSeq[] =
{
{ WM_CAPTURECHANGED, sent },
@ -15977,6 +16108,7 @@ START_TEST(msg)
test_SendMessage_other_thread(1);
test_SendMessage_other_thread(2);
test_InSendMessage();
test_SetFocus();
test_SetParent();
test_PostMessage();
@ -16036,13 +16168,8 @@ START_TEST(msg)
test_keyflags();
test_hotkey();
test_layered_window();
if(!winetest_interactive)
skip("CORE-8299 : Skip Tracking popup menu tests.\n");
else
{
test_TrackPopupMenu();
test_TrackPopupMenuEmpty();
}
test_DoubleSetCapture();
/* keep it the last test, under Windows it tends to break the tests
* which rely on active/foreground windows being correct.
@ -16125,6 +16252,7 @@ START_TEST(msg_queue)
init_tests();
test_SendMessage_other_thread(1);
test_SendMessage_other_thread(2);
test_InSendMessage();
test_PostMessage();
test_broadcast();
test_PeekMessage();

View file

@ -1381,6 +1381,9 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
BOOL isWin9x = FALSE;
HMENU frame_menu = GetMenu(parent);
ok(frame_menu != NULL, "Frame window didn't have a menu\n");
mdi_cs.szClass = "MDI_child_Class_1";
mdi_cs.szTitle = "MDI child";
@ -1424,6 +1427,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1449,6 +1453,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1465,6 +1470,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
@ -1479,6 +1485,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
@ -1499,6 +1506,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1525,6 +1533,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1541,6 +1550,26 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
WS_MAXIMIZE,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
mdi_client, 0, GetModuleHandleA(NULL),
mdi_lParam_test_message);
ok(mdi_child != 0, "MDI child creation failed\n");
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
else
ok(GetMenuItemCount(frame_menu) == 4, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
@ -1555,6 +1584,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
@ -1575,6 +1605,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == first_id, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1601,6 +1632,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
}
@ -1626,6 +1658,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(mdi_child != 0, "MDI child creation failed\n");
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
ok(id == 0, "wrong child id %ld\n", id);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
DestroyWindow(mdi_child);
@ -1641,6 +1674,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == 0, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
DestroyWindow(mdi_child);
/* maximized child */
@ -1655,6 +1689,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == 0, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
DestroyWindow(mdi_child);
trace("Creating maximized child with a caption\n");
@ -1669,6 +1704,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == 0, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
DestroyWindow(mdi_child);
trace("Creating maximized child with a caption and a thick frame\n");
@ -1683,6 +1719,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
ok(id == 0, "wrong child id %ld\n", id);
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
DestroyWindow(mdi_child);
}
@ -1796,7 +1833,7 @@ static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, L
ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
/* MDICREATESTRUCT should have original values */
ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff,
ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff || mdi_cs->style == WS_MAXIMIZE,
"mdi_cs->style does not match (%08x)\n", mdi_cs->style);
ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
@ -2073,11 +2110,12 @@ static BOOL mdi_RegisterWindowClasses(void)
static void test_mdi(void)
{
static const DWORD style[] = { 0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL | WS_VSCROLL };
HWND mdi_hwndMain, mdi_client;
HWND mdi_hwndMain, mdi_client, mdi_child;
CLIENTCREATESTRUCT client_cs;
RECT rc;
DWORD i;
MSG msg;
HMENU frame_menu, child_menu;
if (!mdi_RegisterWindowClasses()) assert(0);
@ -2089,6 +2127,8 @@ static void test_mdi(void)
GetModuleHandleA(NULL), NULL);
assert(mdi_hwndMain);
frame_menu = CreateMenu();
GetClientRect(mdi_hwndMain, &rc);
client_cs.hWindowMenu = 0;
@ -2096,7 +2136,6 @@ static void test_mdi(void)
for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
{
HWND mdi_child;
SCROLLINFO si;
BOOL ret, gotit;
@ -2114,6 +2153,25 @@ static void test_mdi(void)
mdi_lParam_test_message);
ok(mdi_child != 0, "MDI child creation failed\n");
SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
SetMenu(mdi_hwndMain, frame_menu);
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child maximize, but has %u\n",
GetMenuItemCount(frame_menu));
child_menu = CreateMenu();
SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after WM_MDISETMENU, but has %u\n",
GetMenuItemCount(frame_menu));
SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
GetMenuItemCount(frame_menu));
SetMenu(mdi_hwndMain, NULL);
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
ret = GetScrollInfo(mdi_client, SB_HORZ, &si);
@ -2222,10 +2280,46 @@ todo_wine
else
ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]);
DestroyMenu(child_menu);
DestroyWindow(mdi_child);
DestroyWindow(mdi_client);
}
SetMenu(mdi_hwndMain, frame_menu);
mdi_client = CreateWindowExA(0, "mdiclient", NULL,
WS_CHILD,
0, 0, rc.right, rc.bottom,
mdi_hwndMain, 0, 0, &client_cs);
ok(mdi_client != 0, "MDI client creation failed\n");
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
0,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
mdi_client, 0, 0,
mdi_lParam_test_message);
ok(mdi_child != 0, "MDI child creation failed\n");
SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after child maximize, but has %u\n",
GetMenuItemCount(frame_menu));
child_menu = CreateMenu();
SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after WM_MDISETMENU, but has %u\n",
GetMenuItemCount(frame_menu));
SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
GetMenuItemCount(frame_menu));
DestroyMenu(child_menu);
DestroyWindow(mdi_child);
DestroyWindow(mdi_client);
/* MDIClient without MDIS_ALLCHILDSTYLES */
mdi_client = CreateWindowExA(0, "mdiclient",
NULL,
@ -6258,6 +6352,98 @@ static void test_SetWindowLong(void)
}
}
static LRESULT WINAPI check_style_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const STYLESTRUCT *expected = (STYLESTRUCT *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
const STYLESTRUCT *got = (STYLESTRUCT *)lParam;
if (message == WM_STYLECHANGING && wParam == GWL_STYLE)
{
ok(got->styleOld == expected[0].styleOld, "expected old style %#x, got %#x\n",
expected[0].styleOld, got->styleOld);
ok(got->styleNew == expected[0].styleNew, "expected new style %#x, got %#x\n",
expected[0].styleNew, got->styleNew);
}
else if (message == WM_STYLECHANGED && wParam == GWL_STYLE)
{
ok(got->styleOld == expected[1].styleOld, "expected old style %#x, got %#x\n",
expected[1].styleOld, got->styleOld);
ok(got->styleNew == expected[1].styleNew, "expected new style %#x, got %#x\n",
expected[1].styleNew, got->styleNew);
}
return DefWindowProcA(hwnd, message, wParam, lParam);
}
static void test_set_window_style(void)
{
LONG expected_style, new_style, old_style;
STYLESTRUCT expected_stylestruct[2];
unsigned int i;
WNDCLASSA cls;
HWND hwnd;
static const struct
{
LONG creation_style;
LONG style;
}
tests[] =
{
{ WS_MINIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX },
{ WS_MINIMIZE | WS_CLIPSIBLINGS | WS_CAPTION,
WS_CLIPSIBLINGS | WS_CAPTION },
{ WS_MAXIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX },
{ WS_MAXIMIZE | WS_CLIPSIBLINGS | WS_CAPTION,
WS_CLIPSIBLINGS | WS_CAPTION },
{ WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
WS_MINIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX },
{ WS_CLIPSIBLINGS | WS_CAPTION,
WS_MINIMIZE | WS_CLIPSIBLINGS | WS_CAPTION },
{ WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
WS_MAXIMIZE | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX },
{ WS_CLIPSIBLINGS | WS_CAPTION,
WS_MAXIMIZE | WS_CLIPSIBLINGS | WS_CAPTION },
};
memset(&cls, 0, sizeof(cls));
cls.lpfnWndProc = check_style_wnd_proc;
cls.hInstance = GetModuleHandleA(0);
cls.lpszClassName = "TestSetWindowStylesClass";
ok(RegisterClassA(&cls), "RegisterClass failed\n");
for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
{
expected_style = tests[i].style;
if (tests[i].creation_style & WS_MINIMIZE)
expected_style |= WS_MINIMIZE;
expected_stylestruct[0].styleOld = tests[i].creation_style;
expected_stylestruct[0].styleNew = tests[i].style;
expected_stylestruct[1].styleOld = tests[i].creation_style;
expected_stylestruct[1].styleNew = expected_style;
hwnd = CreateWindowA(cls.lpszClassName, "Test set styles",
tests[i].creation_style, 100, 100, 200, 200, 0, 0, 0, NULL);
ok(hwnd != 0, "CreateWindow failed\n");
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)&expected_stylestruct);
old_style = SetWindowLongA(hwnd, GWL_STYLE, tests[i].style);
ok(old_style == tests[i].creation_style, "expected old style %#x, got %#x\n",
tests[i].creation_style, old_style);
new_style = GetWindowLongA(hwnd, GWL_STYLE);
ok(new_style == expected_style, "expected new style %#x, got %#x\n",
expected_style, new_style);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0);
DestroyWindow(hwnd);
}
UnregisterClassA(cls.lpszClassName, cls.hInstance);
}
static void test_ShowWindow(void)
{
HWND hwnd;
@ -9348,6 +9534,7 @@ START_TEST(win)
test_redrawnow();
test_csparentdc();
test_SetWindowLong();
test_set_window_style();
test_ShowWindow();
test_gettext();
test_GetUpdateRect();