Commit b0c45123 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Add a test case for accelerators, make the test pass on Wine.

parent 7c7693f8
...@@ -679,7 +679,6 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, ...@@ -679,7 +679,6 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
{ {
UINT i; UINT i;
key = toupperW(key);
for (i = 0; i < menu->nItems; i++, item++) for (i = 0; i < menu->nItems; i++, item++)
{ {
if (IS_STRING_ITEM(item->fType) && item->text) if (IS_STRING_ITEM(item->fType) && item->text)
...@@ -690,7 +689,7 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, ...@@ -690,7 +689,7 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
p = strchrW (p + 2, '&'); p = strchrW (p + 2, '&');
} }
while (p != NULL && p [1] == '&'); while (p != NULL && p [1] == '&');
if (p && (toupperW(p[1]) == key)) return i; if (p && (toupperW(p[1]) == toupperW(key))) return i;
} }
} }
} }
...@@ -1476,7 +1475,6 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, ...@@ -1476,7 +1475,6 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id,
/* store the owner for DrawItem */ /* store the owner for DrawItem */
menu->hwndOwner = hwndOwner; menu->hwndOwner = hwndOwner;
MENU_PopupMenuCalcSize( menu, hwndOwner ); MENU_PopupMenuCalcSize( menu, hwndOwner );
/* adjust popup menu pos so that it fits within the desktop */ /* adjust popup menu pos so that it fits within the desktop */
...@@ -2848,13 +2846,9 @@ static BOOL MENU_InitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT wFlags) ...@@ -2848,13 +2846,9 @@ static BOOL MENU_InitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT wFlags)
if (!(wFlags & TPM_NONOTIFY)) if (!(wFlags & TPM_NONOTIFY))
{ {
SendMessageW( hWnd, WM_INITMENU, (WPARAM)hMenu, 0 ); SendMessageW( hWnd, WM_INITMENU, (WPARAM)hMenu, 0 );
if ((menu = MENU_GetMenu( hMenu )) && (!menu->Height)) /* If an app changed/recreated menu bar entries in WM_INITMENU
{ /* app changed/recreated menu bar entries in WM_INITMENU * menu sizes will be recalculated once the menu created/shown.
Recalculate menu sizes else clicks will not work */ */
SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
}
} }
/* This makes the menus of applications built with Delphi work. /* This makes the menus of applications built with Delphi work.
...@@ -2927,7 +2921,6 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar) ...@@ -2927,7 +2921,6 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
if (!hTrackMenu || IsIconic(hwnd) || wChar == ' ' ) if (!hTrackMenu || IsIconic(hwnd) || wChar == ' ' )
{ {
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return; if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return;
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_MANAGED) return;
hTrackMenu = get_win_sys_menu( hwnd ); hTrackMenu = get_win_sys_menu( hwnd );
uItem = 0; uItem = 0;
wParam |= HTSYSMENU; /* prevent item lookup */ wParam |= HTSYSMENU; /* prevent item lookup */
...@@ -2940,24 +2933,34 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar) ...@@ -2940,24 +2933,34 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
if( wChar && wChar != ' ' ) if( wChar && wChar != ' ' )
{ {
uItem = MENU_FindItemByKey( hwnd, hTrackMenu, wChar, (wParam & HTSYSMENU) ); uItem = MENU_FindItemByKey( hwnd, hTrackMenu, wChar, (wParam & HTSYSMENU) );
if( uItem >= (UINT)(-2) ) if ( uItem >= (UINT)(-2) )
{ {
if( uItem == (UINT)(-1) ) MessageBeep(0); if( uItem == (UINT)(-1) ) MessageBeep(0);
hTrackMenu = 0; /* schedule end of menu tracking */
PostMessageW( hwnd, WM_CANCELMODE, 0, 0 );
goto track_menu;
} }
} }
else
if( hTrackMenu )
{ {
MENU_SelectItem( hwnd, hTrackMenu, uItem, TRUE, 0 ); /* prevent sysmenu activation for managed windows on Alt down/up */
if ((wParam & HTSYSMENU) && (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MANAGED))
{
/* schedule end of menu tracking */
PostMessageW( hwnd, WM_CANCELMODE, 0, 0 );
goto track_menu;
}
}
if( uItem == NO_SELECTED_ITEM ) MENU_SelectItem( hwnd, hTrackMenu, uItem, TRUE, 0 );
MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT );
else if( wChar )
PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L );
MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL ); if( uItem == NO_SELECTED_ITEM )
} MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT );
else
PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L );
track_menu:
MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL );
MENU_ExitTracking( hwnd ); MENU_ExitTracking( hwnd );
} }
...@@ -4518,13 +4521,17 @@ INT WINAPI MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen) ...@@ -4518,13 +4521,17 @@ INT WINAPI MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen)
static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam,
BYTE fVirt, WORD key, WORD cmd ) BYTE fVirt, WORD key, WORD cmd )
{ {
INT mask = 0;
UINT mesg = 0; UINT mesg = 0;
if (wParam != key) return FALSE; if (wParam != key) return FALSE;
if (GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
if (GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
if (message == WM_CHAR || message == WM_SYSCHAR) if (message == WM_CHAR || message == WM_SYSCHAR)
{ {
if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) ) if ( !(fVirt & FVIRTKEY) && (mask & FALT) == (fVirt & FALT) )
{ {
TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", wParam & 0xff); TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
goto found; goto found;
...@@ -4534,12 +4541,9 @@ static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARA ...@@ -4534,12 +4541,9 @@ static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARA
{ {
if(fVirt & FVIRTKEY) if(fVirt & FVIRTKEY)
{ {
INT mask = 0;
TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n", TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
wParam, 0xff & HIWORD(lParam)); wParam, 0xff & HIWORD(lParam));
if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
if(mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found; if(mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
TRACE_(accel)(", but incorrect SHIFT/CTRL/ALT-state\n"); TRACE_(accel)(", but incorrect SHIFT/CTRL/ALT-state\n");
} }
...@@ -4693,9 +4697,7 @@ INT WINAPI TranslateAcceleratorW( HWND hWnd, HACCEL hAccel, LPMSG msg ) ...@@ -4693,9 +4697,7 @@ INT WINAPI TranslateAcceleratorW( HWND hWnd, HACCEL hAccel, LPMSG msg )
return 0; return 0;
} }
if ( msg->message != WM_KEYDOWN && if ( msg->message != WM_KEYDOWN &&
msg->message != WM_KEYUP &&
msg->message != WM_SYSKEYDOWN && msg->message != WM_SYSKEYDOWN &&
msg->message != WM_SYSKEYUP &&
msg->message != WM_SYSCHAR && msg->message != WM_SYSCHAR &&
msg->message != WM_CHAR ) return 0; msg->message != WM_CHAR ) return 0;
......
...@@ -2267,6 +2267,7 @@ static void test_messages(void) ...@@ -2267,6 +2267,7 @@ static void test_messages(void)
ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n"); ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n"); ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
DestroyWindow(hchild);
DestroyWindow(hparent); DestroyWindow(hparent);
flush_sequence(); flush_sequence();
...@@ -2308,6 +2309,7 @@ static void test_messages(void) ...@@ -2308,6 +2309,7 @@ static void test_messages(void)
EnableWindow(hparent, FALSE); EnableWindow(hparent, FALSE);
ok_sequence(WmEnableWindowSeq, "EnableWindow", FALSE); ok_sequence(WmEnableWindowSeq, "EnableWindow", FALSE);
DestroyWindow(hchild);
DestroyWindow(hparent); DestroyWindow(hparent);
flush_sequence(); flush_sequence();
} }
...@@ -2790,6 +2792,247 @@ static void test_interthread_messages(void) ...@@ -2790,6 +2792,247 @@ static void test_interthread_messages(void)
CloseHandle(hThread); CloseHandle(hThread);
} }
static const struct message WmVkN[] = {
{ WM_KEYDOWN, wparam|lparam, VK_N, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_N, 1 },
{ WM_CHAR, wparam|lparam, 'n', 1 },
{ WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
{ WM_KEYUP, wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_N, 0xc0000001 },
{ 0 }
};
static const struct message WmShiftVkN[] = {
{ WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
{ WM_KEYDOWN, wparam|lparam, VK_N, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_N, 1 },
{ WM_CHAR, wparam|lparam, 'N', 1 },
{ WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
{ WM_KEYUP, wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
{ 0 }
};
static const struct message WmCtrlVkN[] = {
{ WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, wparam|lparam, VK_N, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_N, 1 },
{ WM_CHAR, wparam|lparam, 0x000e, 1 },
{ WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
{ WM_KEYUP, wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
{ 0 }
};
static const struct message WmCtrlVkN_2[] = {
{ WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, wparam|lparam, VK_N, 1 },
{ WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
{ WM_KEYUP, wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_N, 0xc0000001 },
{ WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
{ 0 }
};
static const struct message WmAltVkN[] = {
{ WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
{ WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
{ WM_SYSKEYDOWN, wparam|lparam, VK_N, 0x20000001 },
{ WM_SYSKEYDOWN, sent|wparam|lparam, VK_N, 0x20000001 },
{ WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
{ WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
{ WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
{ HCBT_SYSCOMMAND, hook },
{ WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
{ WM_SETCURSOR, sent|defwinproc },
{ WM_INITMENU, sent|defwinproc },
{ WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
{ WM_CAPTURECHANGED, sent|defwinproc },
{ WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
{ WM_EXITMENULOOP, sent|defwinproc },
{ WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
{ WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
{ WM_SYSKEYUP, wparam|lparam, VK_N, 0xe0000001 },
{ WM_SYSKEYUP, sent|wparam|lparam, VK_N, 0xe0000001 },
{ WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
{ 0 }
};
static const struct message WmAltVkN_2[] = {
{ WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
{ WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
{ WM_SYSKEYDOWN, wparam|lparam, VK_N, 0x20000001 },
{ WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
{ WM_SYSKEYUP, wparam|lparam, VK_N, 0xe0000001 },
{ WM_SYSKEYUP, sent|wparam|lparam, VK_N, 0xe0000001 },
{ WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
{ 0 }
};
static const struct message WmCtrlAltVkN[] = {
{ WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
{ WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
{ WM_KEYDOWN, wparam|lparam, VK_N, 0x20000001 },
{ WM_KEYDOWN, sent|wparam|lparam, VK_N, 0x20000001 },
{ WM_KEYUP, wparam|lparam, VK_N, 0xe0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_N, 0xe0000001 },
{ WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
{ WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
{ WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
{ 0 }
};
static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
{
MSG msg;
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
{
struct message log_msg;
trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
log_msg.message = msg.message;
log_msg.flags = wparam|lparam;
log_msg.wParam = msg.wParam;
log_msg.lParam = msg.lParam;
add_message(&log_msg);
if (!TranslateAccelerator(hwnd, hAccel, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
static void test_accelerators(void)
{
SHORT state;
HACCEL hAccel;
HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
100, 100, 200, 200, 0, 0, 0, NULL);
assert(hwnd != 0);
SetFocus(hwnd);
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
state = GetKeyState(VK_SHIFT);
ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
state = GetKeyState(VK_CAPITAL);
ok(state == 0, "wrong CapsLock state %04x\n", state);
hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
assert(hAccel != 0);
trace("testing VK_N press/release\n");
flush_sequence();
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmVkN, "VK_N press/release", FALSE);
trace("testing Shift+VK_N press/release\n");
flush_sequence();
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
trace("testing Ctrl+VK_N press/release\n");
flush_sequence();
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
trace("testing Alt+VK_N press/release\n");
flush_sequence();
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
trace("testing Ctrl+Alt+VK_N press/release\n");
flush_sequence();
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
ok(DestroyAcceleratorTable(hAccel), "DestroyAcceleratorTable error %ld\n", GetLastError());
hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
assert(hAccel != 0);
trace("testing VK_N press/release\n");
flush_sequence();
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmVkN, "VK_N press/release", FALSE);
trace("testing Shift+VK_N press/release\n");
flush_sequence();
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
trace("testing Ctrl+VK_N press/release 2\n");
flush_sequence();
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
trace("testing Alt+VK_N press/release 2\n");
flush_sequence();
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
trace("testing Ctrl+Alt+VK_N press/release\n");
flush_sequence();
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_N, 0, 0, 0);
keybd_event(VK_N, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
pump_msg_loop(hwnd, hAccel);
ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
ok(DestroyAcceleratorTable(hAccel), "DestroyAcceleratorTable error %ld\n", GetLastError());
DestroyWindow(hwnd);
}
/************* window procedures ********************/ /************* window procedures ********************/
static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
...@@ -3159,6 +3402,7 @@ START_TEST(msg) ...@@ -3159,6 +3402,7 @@ START_TEST(msg)
test_paint_messages(); test_paint_messages();
test_interthread_messages(); test_interthread_messages();
test_message_conversion(); test_message_conversion();
test_accelerators();
UnhookWindowsHookEx(hCBT_hook); UnhookWindowsHookEx(hCBT_hook);
} }
...@@ -20,36 +20,50 @@ ...@@ -20,36 +20,50 @@
#include "windef.h" #include "windef.h"
#include "winuser.h" #include "winuser.h"
STRINGTABLE { 1 ACCELERATORS
0 "String resource" {
"^N", 1000 /* Ctrl+'N' */
"N", 1001 /* Shift+'n' */
"n", 1002 /* 'n' */
}
2 ACCELERATORS
{
78, 1000, VIRTKEY, CONTROL /* Ctrl+'N' */
78, 1001, ASCII /* 'N' */
110, 1002, ASCII /* 'n' */
78, 1003, VIRTKEY, ALT /* Alt+'N' */
}
STRINGTABLE
{
0 "String resource"
} }
TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30 TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
CAPTION "Test dialog" CAPTION "Test dialog"
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg"
BEGIN {
DEFPUSHBUTTON "OK", IDOK,4,4,50,14, WS_TABSTOP | WS_GROUP DEFPUSHBUTTON "OK", IDOK,4,4,50,14, WS_TABSTOP | WS_GROUP
END }
RADIO_TEST_DIALOG DIALOGEX 0, 0, 160, 80 RADIO_TEST_DIALOG DIALOGEX 0, 0, 160, 80
STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Radio Button Test Dialog" CAPTION "Radio Button Test Dialog"
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg"
BEGIN {
GROUPBOX "Static", 100,6,5,92,70 GROUPBOX "Static", 100,6,5,92,70
CONTROL "Radio1", 200,"Button",BS_AUTORADIOBUTTON | CONTROL "Radio1", 200,"Button",BS_AUTORADIOBUTTON |
WS_GROUP | WS_TABSTOP,17,27,39,10 WS_GROUP | WS_TABSTOP,17,27,39,10
CONTROL "Radio2", 201,"Button",BS_AUTORADIOBUTTON,17,40,39,10 CONTROL "Radio2", 201,"Button",BS_AUTORADIOBUTTON,17,40,39,10
PUSHBUTTON "Cancel", IDCANCEL,109,20,50,14, WS_TABSTOP | WS_GROUP PUSHBUTTON "Cancel", IDCANCEL,109,20,50,14, WS_TABSTOP | WS_GROUP
END }
CLASS_TEST_DIALOG DIALOG DISCARDABLE 0, 0, 91, 28 CLASS_TEST_DIALOG DIALOG DISCARDABLE 0, 0, 91, 28
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "CreateDialogParams Test" CAPTION "CreateDialogParams Test"
CLASS "TestDialog" CLASS "TestDialog"
FONT 8, "System" FONT 8, "System"
BEGIN {
END }
...@@ -2061,6 +2061,12 @@ INT X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState, ...@@ -2061,6 +2061,12 @@ INT X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
if (hkl != X11DRV_GetKeyboardLayout(0)) if (hkl != X11DRV_GetKeyboardLayout(0))
FIXME("keyboard layout %p is not supported\n", hkl); FIXME("keyboard layout %p is not supported\n", hkl);
if ((lpKeyState[VK_MENU] & 0x80) && (lpKeyState[VK_CONTROL] & 0x80))
{
TRACE("Ctrl+Alt+[key] won't generate a character\n");
return 0;
}
e.display = display; e.display = display;
e.keycode = 0; e.keycode = 0;
e.state = 0; e.state = 0;
......
...@@ -553,10 +553,9 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa ...@@ -553,10 +553,9 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
} }
} }
else if( wParam == VK_F10 ) else if( wParam == VK_F10 )
iF10Key = 1; iF10Key = 1;
else else if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000)) SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
break; break;
case WM_KEYUP: case WM_KEYUP:
......
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