user32: Partially implement FlashWindowEx with tests

André Hentschel nerv at dawncrow.de
Sat May 21 16:14:31 CDT 2011


---
 dlls/user32/tests/win.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/user32/win.c       |   26 +++++++++++++-
 2 files changed, 112 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 278a282..c67e4fb 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -56,6 +56,7 @@ static int  (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
 static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
 static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
 static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout );
+static BOOL (WINAPI *pFlashWindowEx)( PFLASHWINFO pfwi );
 static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
 static DWORD (WINAPI *pGetLayout)(HDC hdc);
 static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn);
@@ -6446,6 +6447,90 @@ static void test_rtl_layout(void)
     DestroyWindow( parent );
 }
 
+static void test_FlashWindowEx(void)
+{
+    HWND hwnd;
+    FLASHWINFO finfo;
+    BOOL ret;
+
+    if (!pFlashWindowEx)
+    {
+        win_skip( "FlashWindowEx not supported\n" );
+        return;
+    }
+
+    hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP,
+                            0, 0, 0, 0, 0, 0, 0, NULL );
+    ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
+
+    finfo.cbSize = sizeof(FLASHWINFO);
+    finfo.dwFlags = FLASHW_TIMER;
+    finfo.uCount = 3;
+    finfo.dwTimeout = 200;
+    finfo.hwnd = NULL;
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+                 "FlashWindowEx returned with %d\n", GetLastError());
+
+    finfo.hwnd = hwnd;
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(NULL);
+    ok(!ret && GetLastError() == ERROR_NOACCESS,
+       "FlashWindowEx returned with %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    todo_wine ok(!ret, "FlashWindowEx succeeded\n");
+
+    finfo.cbSize = sizeof(FLASHWINFO) - 1;
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    ok(!ret && GetLastError()==ERROR_INVALID_PARAMETER,
+       "FlashWindowEx succeeded\n");
+    finfo.cbSize = sizeof(FLASHWINFO);
+
+    DestroyWindow( hwnd );
+
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
+       "FlashWindowEx returned with %d\n", GetLastError());
+
+    ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
+    ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
+    ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %x\n", finfo.dwFlags);
+    ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
+    ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %x\n", finfo.dwTimeout);
+
+    hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE | WS_POPUPWINDOW,
+                            0, 0, 0, 0, 0, 0, 0, NULL );
+    ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
+    finfo.hwnd = hwnd;
+
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(NULL);
+    ok(!ret && GetLastError() == ERROR_NOACCESS,
+       "FlashWindowEx returned with %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    todo_wine ok(!ret, "FlashWindowEx succeeded\n");
+
+    ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
+    ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
+    ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %x\n", finfo.dwFlags);
+    ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
+    ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %x\n", finfo.dwTimeout);
+
+    finfo.dwFlags = FLASHW_STOP;
+    SetLastError(0xdeadbeef);
+    ret = pFlashWindowEx(&finfo);
+    ok(ret, "FlashWindowEx failed with %d\n", GetLastError());
+
+    DestroyWindow( hwnd );
+}
+
 static void test_FindWindowEx(void)
 {
     HWND hwnd, found;
@@ -6518,6 +6603,7 @@ START_TEST(win)
     pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
     pGetProcessDefaultLayout = (void *)GetProcAddress( user32, "GetProcessDefaultLayout" );
     pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" );
+    pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" );
     pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" );
     pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
     pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
@@ -6562,6 +6648,7 @@ START_TEST(win)
     test_capture_3(hwndMain, hwndMain2);
     test_capture_4();
     test_rtl_layout();
+    test_FlashWindowEx();
 
     test_CreateWindow();
     test_parent_owner();
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index b61d183..bc376ee 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3261,7 +3261,31 @@ BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
  */
 BOOL WINAPI FlashWindowEx( PFLASHWINFO pfwi )
 {
-    FIXME("%p\n", pfwi);
+    UINT i, msecs;
+
+    if (!pfwi)
+    {
+        SetLastError(ERROR_NOACCESS);
+        return FALSE;
+    }
+    if (!pfwi->hwnd || pfwi->cbSize < sizeof(FLASHWINFO))
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    FIXME("%p semi-stub\n", pfwi);
+
+    if (pfwi->dwTimeout) msecs = pfwi->dwTimeout;
+    else msecs = GetProfileIntA( "windows", "CursorBlinkRate", 500 );
+
+    for (i=0; i<pfwi->uCount + 1; i++)
+    {
+        FlashWindow(pfwi->hwnd, TRUE);
+        Sleep(msecs);
+        FlashWindow(pfwi->hwnd, FALSE);
+        Sleep(msecs);
+    }
     return TRUE;
 }
 
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list