<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
This patch adds test for edit control clipboard context menu.<br>The test passes on Windows XP as the WM_COMMAND message is not sent to the edit control by its context menu.<br>Fails on wine because wine does incorrectly send that message.<br>This problem shows up using the edit class context menu on application created with vb6.0, which leads to application crashing.<br><br>The code does not use WINE_TODO() because a simple fix for this will be sent when<br>this problem is accepted.<br><br>Mike<br><style>.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>


<style>
.ExternalClass p, .ExternalClass li
{white-space:pre-wrap;}�</style><br><p style="text-indent: 0px;">---<br></p>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"><!--StartFragment--> dlls/user32/tests/edit.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++</p>
<p style="margin: 0px; text-indent: 0px;"> 1 files changed, 81 insertions(+), 0 deletions(-)</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c</p>
<p style="margin: 0px; text-indent: 0px;">index 5ca012e..598b486 100644</p>
<p style="margin: 0px; text-indent: 0px;">--- a/dlls/user32/tests/edit.c</p>
<p style="margin: 0px; text-indent: 0px;">+++ b/dlls/user32/tests/edit.c</p>
<p style="margin: 0px; text-indent: 0px;">@@ -36,6 +36,7 @@ struct edit_notify {</p>
<p style="margin: 0px; text-indent: 0px;">     int en_change, en_maxtext, en_update;</p>
<p style="margin: 0px; text-indent: 0px;"> };</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;">+static WNDPROC editWndProc;</p>
<p style="margin: 0px; text-indent: 0px;"> static struct edit_notify notifications;</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;"> static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)</p>
<p style="margin: 0px; text-indent: 0px;">@@ -533,6 +534,69 @@ static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM</p>
<p style="margin: 0px; text-indent: 0px;">     return FALSE;</p>
<p style="margin: 0px; text-indent: 0px;"> }</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;">+static LRESULT CALLBACK edit_control_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)</p>
<p style="margin: 0px; text-indent: 0px;">+{</p>
<p style="margin: 0px; text-indent: 0px;">+    static int timerCount = 0;</p>
<p style="margin: 0px; text-indent: 0px;">+    HGLOBAL cbData;</p>
<p style="margin: 0px; text-indent: 0px;">+    LPSTR lpStrCopy;</p>
<p style="margin: 0px; text-indent: 0px;">+    LPARAM mousePos;</p>
<p style="margin: 0px; text-indent: 0px;">+    HWND findHwnd;</p>
<p style="margin: 0px; text-indent: 0px;">+    RECT winRect;</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;">+    ok(msg != WM_COMMAND, "Should not have received WM_COMMAND\n");</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;">+    switch(msg)</p>
<p style="margin: 0px; text-indent: 0px;">+    {</p>
<p style="margin: 0px; text-indent: 0px;">+        case WM_TIMER:</p>
<p style="margin: 0px; text-indent: 0px;">+            /* Using a timer here to move the menu selection down to the paste menu item and then select it.</p>
<p style="margin: 0px; text-indent: 0px;">+               We are trying to show that on windows the clipboard context menu does not</p>
<p style="margin: 0px; text-indent: 0px;">+               send WM_COMMAND messages to the edit class windows procedure. */</p>
<p style="margin: 0px; text-indent: 0px;">+            switch(timerCount)</p>
<p style="margin: 0px; text-indent: 0px;">+            {</p>
<p style="margin: 0px; text-indent: 0px;">+                case 0:</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Copy some data to clipboard */</p>
<p style="margin: 0px; text-indent: 0px;">+                    cbData = GlobalAlloc(GMEM_MOVEABLE, 5);</p>
<p style="margin: 0px; text-indent: 0px;">+                    lpStrCopy = (LPSTR)GlobalLock(cbData);</p>
<p style="margin: 0px; text-indent: 0px;">+                    memcpy(lpStrCopy, "test\0", 5);</p>
<p style="margin: 0px; text-indent: 0px;">+                    OpenClipboard(hwnd);</p>
<p style="margin: 0px; text-indent: 0px;">+                    SetClipboardData(CF_TEXT, cbData);</p>
<p style="margin: 0px; text-indent: 0px;">+                    CloseClipboard();</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Move mouse to upper left of text control */</p>
<p style="margin: 0px; text-indent: 0px;">+                    GetWindowRect(hwnd, &amp;winRect);</p>
<p style="margin: 0px; text-indent: 0px;">+                    SetCursorPos(winRect.left, winRect.top);</p>
<p style="margin: 0px; text-indent: 0px;">+                    mousePos = MAKELPARAM(winRect.left + 20, winRect.top + 20);</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Show the Context Menu */</p>
<p style="margin: 0px; text-indent: 0px;">+                    PostMessage(hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, mousePos);</p>
<p style="margin: 0px; text-indent: 0px;">+                    break;</p>
<p style="margin: 0px; text-indent: 0px;">+                case 1:</p>
<p style="margin: 0px; text-indent: 0px;">+                case 2:</p>
<p style="margin: 0px; text-indent: 0px;">+                case 3:</p>
<p style="margin: 0px; text-indent: 0px;">+                case 4:</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Find the menu window and send keydown.</p>
<p style="margin: 0px; text-indent: 0px;">+                       Do this four times to move menu selection to the paste menu item */</p>
<p style="margin: 0px; text-indent: 0px;">+                    findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL);</p>
<p style="margin: 0px; text-indent: 0px;">+                    PostMessage(findHwnd, WM_KEYDOWN, VK_DOWN,0);</p>
<p style="margin: 0px; text-indent: 0px;">+                    break;</p>
<p style="margin: 0px; text-indent: 0px;">+                case 5:</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Find the menu window and send return, selecting the paste menu item */</p>
<p style="margin: 0px; text-indent: 0px;">+                    findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL);</p>
<p style="margin: 0px; text-indent: 0px;">+                    PostMessage(findHwnd, WM_KEYDOWN, VK_RETURN,0);</p>
<p style="margin: 0px; text-indent: 0px;">+                    break;</p>
<p style="margin: 0px; text-indent: 0px;">+                case 6:</p>
<p style="margin: 0px; text-indent: 0px;">+                    /* Kill the timer as we are done */</p>
<p style="margin: 0px; text-indent: 0px;">+                    KillTimer(hwnd, 1);</p>
<p style="margin: 0px; text-indent: 0px;">+                    PostQuitMessage(0);</p>
<p style="margin: 0px; text-indent: 0px;">+                    break;</p>
<p style="margin: 0px; text-indent: 0px;">+            }</p>
<p style="margin: 0px; text-indent: 0px;">+            timerCount++;</p>
<p style="margin: 0px; text-indent: 0px;">+            break;</p>
<p style="margin: 0px; text-indent: 0px;">+    }</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;">+    /* Call the defauly window proc for the edit class */</p>
<p style="margin: 0px; text-indent: 0px;">+    return CallWindowProc(editWndProc, hwnd, msg, wparam, lparam);</p>
<p style="margin: 0px; text-indent: 0px;">+}</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;"> static HINSTANCE hinst;</p>
<p style="margin: 0px; text-indent: 0px;"> static HWND hwndET2;</p>
<p style="margin: 0px; text-indent: 0px;"> static const char szEditTest2Class[] = "EditTest2Class";</p>
<p style="margin: 0px; text-indent: 0px;">@@ -2260,6 +2324,22 @@ static void test_dialogmode(void)</p>
<p style="margin: 0px; text-indent: 0px;">     destroy_child_editcontrol(hwEdit);</p>
<p style="margin: 0px; text-indent: 0px;"> }</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;">+static void test_contextmenu(void)</p>
<p style="margin: 0px; text-indent: 0px;">+{</p>
<p style="margin: 0px; text-indent: 0px;">+    HWND hwEdit;</p>
<p style="margin: 0px; text-indent: 0px;">+    LONG Timer1;</p>
<p style="margin: 0px; text-indent: 0px;">+    hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);</p>
<p style="margin: 0px; text-indent: 0px;">+    editWndProc = (WNDPROC)SetWindowLongPtr(hwEdit, GWLP_WNDPROC,(LRESULT)edit_control_wndproc);</p>
<p style="margin: 0px; text-indent: 0px;">+    ShowWindow(hwEdit, SW_SHOW);</p>
<p style="margin: 0px; text-indent: 0px;">+    Timer1 = SetTimer(hwEdit, 1, 100, NULL);</p>
<p style="margin: 0px; text-indent: 0px;">+    MSG msg;</p>
<p style="margin: 0px; text-indent: 0px;">+    while (GetMessage(&amp;msg, 0, 0, 0) &gt; 0)</p>
<p style="margin: 0px; text-indent: 0px;">+    {</p>
<p style="margin: 0px; text-indent: 0px;">+        TranslateMessage(&amp;msg);</p>
<p style="margin: 0px; text-indent: 0px;">+        DispatchMessage(&amp;msg);</p>
<p style="margin: 0px; text-indent: 0px;">+    }</p>
<p style="margin: 0px; text-indent: 0px;">+}</p>
<p style="margin: 0px; text-indent: 0px;">+</p>
<p style="margin: 0px; text-indent: 0px;"> START_TEST(edit)</p>
<p style="margin: 0px; text-indent: 0px;"> {</p>
<p style="margin: 0px; text-indent: 0px;">     hinst = GetModuleHandleA(NULL);</p>
<p style="margin: 0px; text-indent: 0px;">@@ -2285,6 +2365,7 @@ START_TEST(edit)</p>
<p style="margin: 0px; text-indent: 0px;">     test_child_edit_wmkeydown();</p>
<p style="margin: 0px; text-indent: 0px;">     test_fontsize();</p>
<p style="margin: 0px; text-indent: 0px;">     test_dialogmode();</p>
<p style="margin: 0px; text-indent: 0px;">+    test_contextmenu();</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;">     UnregisterWindowClasses();</p>
<p style="margin: 0px; text-indent: 0px;"> }</p>
<p style="margin: 0px; text-indent: 0px;"><!--EndFragment--></p><p style="margin: 0px; text-indent: 0px;"><!--EndFragment--></p><a href="http://clk.atdmt.com/GBL/go/171222986/direct/01/"></a>                                               <br /><hr />Hotmail: Trusted email with powerful SPAM protection. <a href='http://clk.atdmt.com/GBL/go/177141665/direct/01/' target='_new'>Sign up now.</a></body>
</html>