Re: [PATCH] Add test case to user32 winetests for edit control contextmenu.
"Michael Martin" <martinmnet(a)hotmail.com> wrote:
+WNDPROC editWndProc;
Should be static.
+static INT_PTR CALLBACK edit_control_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
INT_PTR is wrong return type for a window proc.
+{ + static int timerCount = 0; + HGLOBAL cbData; + LPTSTR lptStrCopy; + LPARAM mousePos; + HWND findHwnd; + RECT winRect; + + ok(msg != WM_COMMAND, "Should not have received WM_COMMAND\n"); + + switch(msg) + { + case WM_TIMER: + switch(timerCount) + { + case 0: + /* Copy some data to clipboard */ + cbData = GlobalAlloc(GMEM_MOVEABLE, 5); + lptStrCopy = (TCHAR*)GlobalLock(cbData); + memcpy(lptStrCopy, "test", 4); + OpenClipboard(hwnd); + SetClipboardData(CF_TEXT, cbData); + CloseClipboard();
TCHAR should be never used in Wine. String above is not 0 terminated. A comment explaining that you want to enable some menu item would be helpful as well.
+ + /* 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 */ + 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 menu item */ + findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL); + PostMessage(findHwnd, WM_KEYDOWN, VK_RETURN,0); + break;
You should use the menu notification messages instead of FindWindowEx above.
+ editWndProc = (WNDPROC)SetWindowLong(hwEdit, GWL_WNDPROC,(LONG)edit_control_wndproc);
SetWindowLongPtr() should be used here with appropriate GWLP_ value. If the test doesn't pass under Wine you sould use todo_wine(). -- Dmitry.
participants (1)
-
Dmitry Timoshkov