dlls/user32/tests/edit.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 5ca012e..721e85f 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -36,6 +36,7 @@ struct edit_notify { int en_change, en_maxtext, en_update; }; +static WNDPROC editWndProc; static struct edit_notify notifications; static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) @@ -533,6 +534,71 @@ static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM return FALSE; } +static LRESULT CALLBACK edit_control_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + static int timerCount = 0; + HGLOBAL cbData; + LPSTR lpStrCopy; + LPARAM mousePos; + HWND findHwnd; + RECT winRect; + + todo_wine{ + ok(msg != WM_COMMAND, "Should not have received WM_COMMAND\n"); + } + + switch(msg) + { + case WM_TIMER: + /* Using a timer here to move the menu selection down to the paste menu item and then select it. + Not using anything as we are trying to show that on windows the clipboard context menu does not + send WM_COMMAND messages to the edit class procedure. */ + switch(timerCount) + { + case 0: + /* Copy some data to clipboard */ + cbData = GlobalAlloc(GMEM_MOVEABLE, 5); + lpStrCopy = (LPSTR)GlobalLock(cbData); + memcpy(lpStrCopy, "test\0", 5); + OpenClipboard(hwnd); + SetClipboardData(CF_TEXT, cbData); + CloseClipboard(); + + /* Move mouse to upper left of text control */ + GetWindowRect(hwnd, &winRect); + SetCursorPos(winRect.left, winRect.top); + mousePos = MAKELPARAM(winRect.left + 20, winRect.top + 20); + /* Show the Context Menu */ + PostMessage(hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, mousePos); + break; + case 1: + case 2: + case 3: + case 4: + /* Find the menu window and send keydown. + Do this four times to move menu selection to the paste menu item */ + findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL); + PostMessage(findHwnd, WM_KEYDOWN, VK_DOWN,0); + break; + case 5: + /* Find the menu window and send return, selecting the paste menu item */ + findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL); + PostMessage(findHwnd, WM_KEYDOWN, VK_RETURN,0); + break; + case 6: + /* Kill the timer as we are done */ + KillTimer(hwnd, 1); + PostQuitMessage(0); + break; + } + timerCount++; + break; + } + + /* Call the default window proc for the edit class */ + return CallWindowProc(editWndProc, hwnd, msg, wparam, lparam); +} + static HINSTANCE hinst; static HWND hwndET2; static const char szEditTest2Class[] = "EditTest2Class"; @@ -2260,6 +2326,22 @@ static void test_dialogmode(void) destroy_child_editcontrol(hwEdit); } +static void test_contextmenu(void) +{ + HWND hwEdit; + LONG Timer1; + hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + editWndProc = (WNDPROC)SetWindowLongPtr(hwEdit, GWLP_WNDPROC,(LRESULT)edit_control_wndproc); + ShowWindow(hwEdit, SW_SHOW); + Timer1 = SetTimer(hwEdit, 1, 100, NULL); + MSG msg; + while (GetMessage(&msg, 0, 0, 0) > 0) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + START_TEST(edit) { hinst = GetModuleHandleA(NULL); @@ -2285,6 +2367,7 @@ START_TEST(edit) test_child_edit_wmkeydown(); test_fontsize(); test_dialogmode(); + test_contextmenu(); UnregisterWindowClasses(); }