ReactOS  0.4.14-dev-815-ge410a12
PaintDesktop.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: rostests/win32/user32/paintdesktop/PaintDesktop.c
5  *
6  * PURPOSE: Demonstrates how the user32!PaintDesktop() API visually works.
7  * This API paints the desktop inside the given HDC with its
8  * origin always fixed to the origin of the monitor on which
9  * the window is present.
10  *
11  * PROGRAMMER: Hermes Belusca-Maito
12  */
13 
14 #define WIN32_LEAN_AND_MEAN
15 #include <windows.h>
16 
18 static PWSTR szTitle = L"PaintDesktop";
19 static PWSTR szWindowClass = L"PAINTDESKTOP";
20 
24 
26  HINSTANCE hPrevInstance,
27  LPWSTR lpCmdLine,
28  int nCmdShow)
29 {
30  MSG msg;
31 
32  UNREFERENCED_PARAMETER(hPrevInstance);
33  UNREFERENCED_PARAMETER(lpCmdLine);
34 
36 
37  if (!InitInstance (hInstance, nCmdShow))
38  return FALSE;
39 
40  while (GetMessage(&msg, NULL, 0, 0))
41  {
44  }
45 
46  return (int) msg.wParam;
47 }
48 
50 {
51  WNDCLASS wc;
52 
53  wc.style = 0;
54  wc.lpfnWndProc = WndProc;
55  wc.cbClsExtra = 0;
56  wc.cbWndExtra = 0;
57  wc.hInstance = hInstance;
60  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
61  wc.lpszMenuName = NULL;
63 
64  return RegisterClass(&wc);
65 }
66 
68 {
69  HWND hWnd;
70 
71  hInst = hInstance;
72 
75  if (!hWnd)
76  return FALSE;
77 
78  ShowWindow(hWnd, nCmdShow);
80 
81  return TRUE;
82 }
83 
85 {
86  switch (message)
87  {
88  case WM_MOVE:
91  break;
92 
93  case WM_ERASEBKGND:
94  return (LRESULT)PaintDesktop((HDC)wParam);
95 
96  case WM_DESTROY:
97  PostQuitMessage(0);
98  break;
99 
100  default:
102  }
103 
104  return 0;
105 }
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
Definition: PaintDesktop.c:84
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Definition: PaintDesktop.c:25
#define CreateWindow
Definition: winuser.h:5729
WORD ATOM
Definition: dimm.idl:113
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
uint16_t * PWSTR
Definition: typedefs.h:54
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
int cbClsExtra
Definition: winuser.h:3140
#define WM_MOVE
Definition: winuser.h:1592
LPCSTR lpszMenuName
Definition: winuser.h:3146
UINT_PTR WPARAM
Definition: windef.h:207
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define COLOR_WINDOW
Definition: winuser.h:908
WPARAM wParam
Definition: combotst.c:138
int cbWndExtra
Definition: winuser.h:3141
HINSTANCE hInstance
Definition: charmap.c:20
unsigned int BOOL
Definition: ntddk_ex.h:94
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
static PWSTR szTitle
Definition: PaintDesktop.c:18
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define IDI_WINLOGO
Definition: winuser.h:704
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
static const WCHAR L[]
Definition: oid.c:1250
static HINSTANCE hInst
Definition: PaintDesktop.c:17
BOOL InitInstance(HINSTANCE, int)
Definition: PaintDesktop.c:67
LPCSTR lpszClassName
Definition: winuser.h:3147
ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: PaintDesktop.c:49
UINT style
Definition: winuser.h:3138
HINSTANCE hInstance
Definition: winuser.h:3142
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5765
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BOOL WINAPI PaintDesktop(_In_ HDC)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define RegisterClass
Definition: winuser.h:5811
#define WM_ERASEBKGND
Definition: winuser.h:1607
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static PWSTR szWindowClass
Definition: PaintDesktop.c:19
#define APIENTRY
Definition: api.h:79
HICON hIcon
Definition: winuser.h:3143