user32: Don't emit WM_COMMAND on choosing an item in a context menu (Edit control).

This commit is contained in:
Akihiro Sagawa 2014-04-08 01:43:51 +09:00 committed by Alexandre Julliard
parent 1ba63827f2
commit 0bfc8f05c6
2 changed files with 10 additions and 11 deletions

View File

@ -3244,14 +3244,11 @@ static LRESULT EDIT_WM_Char(EDITSTATE *es, WCHAR c)
/*********************************************************************
*
* WM_COMMAND
* EDIT_ContextMenuCommand
*
*/
static void EDIT_WM_Command(EDITSTATE *es, INT code, INT id, HWND control)
static void EDIT_ContextMenuCommand(EDITSTATE *es, UINT id)
{
if (code || control)
return;
switch (id) {
case EM_UNDO:
SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
@ -3301,6 +3298,7 @@ static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
HMENU popup = GetSubMenu(menu, 0);
UINT start = es->selection_start;
UINT end = es->selection_end;
UINT cmd;
ORDER_UINT(start, end);
@ -3329,7 +3327,12 @@ static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
if (!(es->flags & EF_FOCUSED))
SetFocus(es->hwndSelf);
TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, es->hwndSelf, NULL);
cmd = TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY,
x, y, 0, es->hwndSelf, NULL);
if (cmd)
EDIT_ContextMenuCommand(es, cmd);
DestroyMenu(menu);
}
@ -4984,10 +4987,6 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B
EDIT_WM_Clear(es);
break;
case WM_COMMAND:
EDIT_WM_Command(es, HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
break;
case WM_CONTEXTMENU:
EDIT_WM_ContextMenu(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
break;

View File

@ -2323,7 +2323,7 @@ static void test_contextmenu(void)
SendMessageA(hwndEdit, WM_SETTEXT, 0, (LPARAM)"foo");
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(-1, -1));
while (PeekMessageA(&msg, hwndEdit, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
todo_wine ok(menu_messages.wm_command == 0,
ok(menu_messages.wm_command == 0,
"Expected no WM_COMMAND messages, got %d\n", menu_messages.wm_command);
todo_wine ok(menu_messages.em_setsel == 1,
"Expected 1 EM_SETSEL message, got %d\n", menu_messages.em_setsel);