Aric Stewart : user32: Add test demonstrating the WM_PAINT loop.

Alexandre Julliard julliard at winehq.org
Wed Aug 27 08:24:51 CDT 2008


Module: wine
Branch: master
Commit: 3f9aec17cd7ecb01ea72747d7f9e1f6572b1303b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3f9aec17cd7ecb01ea72747d7f9e1f6572b1303b

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Aug 26 09:55:05 2008 -0500

user32: Add test demonstrating the WM_PAINT loop.

---

 dlls/user32/tests/msg.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 7480e1b..62cc2dc 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -1584,6 +1584,7 @@ static int after_end_dialog, test_def_id;
 static int sequence_cnt, sequence_size;
 static struct message* sequence;
 static int log_all_parent_messages;
+static int paint_loop_done;
 
 /* user32 functions */
 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
@@ -7039,6 +7040,31 @@ static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LP
     return ret;
 }
 
+LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg)
+    {
+        case WM_CREATE: return 0;
+        case WM_PAINT:
+        {
+            MSG msg2;
+            static int i = 0;
+
+            i++;
+            if (PeekMessageA(&msg2, 0, 0, 0, 1))
+            {
+                TranslateMessage(&msg2);
+                DispatchMessage(&msg2);
+            }
+            i--;
+            if ( i == 0)
+                paint_loop_done = 1;
+            return DefWindowProcA(hWnd,msg,wParam,lParam);
+        }
+    }
+    return DefWindowProcA(hWnd,msg,wParam,lParam);
+}
+
 static BOOL RegisterWindowClasses(void)
 {
     WNDCLASSA cls;
@@ -7072,6 +7098,10 @@ static BOOL RegisterWindowClasses(void)
     cls.lpszClassName = "SimpleWindowClass";
     if(!RegisterClassA(&cls)) return FALSE;
 
+    cls.lpfnWndProc = PaintLoopProcA;
+    cls.lpszClassName = "PaintLoopWindowClass";
+    if(!RegisterClassA(&cls)) return FALSE;
+
     cls.style = CS_NOCLOSE;
     cls.lpszClassName = "NoCloseWindowClass";
     if(!RegisterClassA(&cls)) return FALSE;
@@ -11033,6 +11063,31 @@ static void test_menu_messages(void)
     DestroyMenu(hmenu);
 }
 
+
+static void test_paintingloop(void)
+{
+    HWND hwnd;
+
+    paint_loop_done = 0;
+    hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass",
+                               "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW,
+                                100, 100, 100, 100, 0, 0, 0, NULL );
+    ok(hwnd != 0, "PaintLoop window error %u\n", GetLastError());
+    ShowWindow(hwnd,SW_NORMAL);
+    SetFocus(hwnd);
+
+    while (!paint_loop_done)
+    {
+        MSG msg;
+        if (PeekMessageA(&msg, 0, 0, 0, 1))
+        {
+            TranslateMessage(&msg);
+            DispatchMessage(&msg);
+        }
+    }
+    DestroyWindow(hwnd);
+}
+
 START_TEST(msg)
 {
     BOOL ret;
@@ -11116,6 +11171,7 @@ START_TEST(msg)
     test_nullCallback();
     test_dbcs_wm_char();
     test_menu_messages();
+    test_paintingloop();
     /* keep it the last test, under Windows it tends to break the tests
      * which rely on active/foreground windows being correct.
      */




More information about the wine-cvs mailing list