[ROSTESTS:USER32] Add an interactive test demonstrating how the PaintDesktop API...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 12 Jun 2016 14:34:58 +0000 (14:34 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 12 Jun 2016 14:34:58 +0000 (14:34 +0000)
svn path=/trunk/; revision=71622

rostests/win32/user32/CMakeLists.txt
rostests/win32/user32/paintdesktop/CMakeLists.txt [new file with mode: 0644]
rostests/win32/user32/paintdesktop/PaintDesktop.c [new file with mode: 0644]

index ae7ed50..b61af83 100644 (file)
@@ -1 +1,2 @@
+add_subdirectory(paintdesktop)
 add_subdirectory(sysicon)
diff --git a/rostests/win32/user32/paintdesktop/CMakeLists.txt b/rostests/win32/user32/paintdesktop/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ebf9ecd
--- /dev/null
@@ -0,0 +1,5 @@
+
+add_executable(paintdesktop PaintDesktop.c)
+set_module_type(paintdesktop win32gui UNICODE)
+add_importlibs(paintdesktop user32 msvcrt kernel32)
+add_cd_file(TARGET paintdesktop DESTINATION reactos/bin FOR all)
diff --git a/rostests/win32/user32/paintdesktop/PaintDesktop.c b/rostests/win32/user32/paintdesktop/PaintDesktop.c
new file mode 100644 (file)
index 0000000..c14825c
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * PaintDesktop.c
+ *
+ * Demonstrates how the user32!PaintDesktop() API visually works.
+ * This API paints the desktop inside the given HDC with its origin
+ * always fixed to the origin of the monitor on which the window is
+ * present.
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+static HINSTANCE hInst;
+static PWSTR szTitle       = L"PaintDesktop";
+static PWSTR szWindowClass = L"PAINTDESKTOP";
+
+ATOM                MyRegisterClass(HINSTANCE hInstance);
+BOOL                InitInstance(HINSTANCE, int);
+LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
+
+int APIENTRY wWinMain(HINSTANCE hInstance,
+                      HINSTANCE hPrevInstance,
+                      LPWSTR    lpCmdLine,
+                      int       nCmdShow)
+{
+    MSG msg;
+
+    UNREFERENCED_PARAMETER(hPrevInstance);
+    UNREFERENCED_PARAMETER(lpCmdLine);
+
+    MyRegisterClass(hInstance);
+
+    if (!InitInstance (hInstance, nCmdShow))
+        return FALSE;
+
+    while (GetMessage(&msg, NULL, 0, 0))
+    {
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+
+    return (int) msg.wParam;
+}
+
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+    WNDCLASS wc;
+
+    wc.style          = CS_HREDRAW | CS_VREDRAW;
+    wc.lpfnWndProc    = WndProc;
+    wc.cbClsExtra     = 0;
+    wc.cbWndExtra     = 0;
+    wc.hInstance      = hInstance;
+    wc.hIcon          = LoadIconW(NULL, IDI_WINLOGO);
+    wc.hCursor        = LoadCursorW(NULL, IDC_ARROW);
+    wc.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
+    wc.lpszMenuName   = NULL;
+    wc.lpszClassName  = szWindowClass;
+
+    return RegisterClass(&wc);
+}
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+    HWND hWnd;
+
+    hInst = hInstance;
+
+    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+                        CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+    if (!hWnd)
+        return FALSE;
+
+    ShowWindow(hWnd, nCmdShow);
+    UpdateWindow(hWnd);
+
+    return TRUE;
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message)
+    {
+        case WM_MOVE:
+            InvalidateRect(hWnd, NULL, TRUE);
+            UpdateWindow(hWnd);
+            break;
+
+        case WM_ERASEBKGND:
+            PaintDesktop((HDC)wParam);
+            break;
+
+        case WM_DESTROY:
+            PostQuitMessage(0);
+            break;
+
+        default:
+            return DefWindowProc(hWnd, message, wParam, lParam);
+    }
+
+    return 0;
+}