ReactOS 0.4.15-dev-7842-g558ab78
wm_paint.c File Reference
#include <windows.h>
#include <string.h>
Include dependency graph for wm_paint.c:

Go to the source code of this file.

Functions

LRESULT CALLBACK MainWndProc (HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
 
int APIENTRY WinMain (HINSTANCE HInstance, HINSTANCE HPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
 

Variables

const charWndClassName = "GMainWnd"
 

Function Documentation

◆ MainWndProc()

LRESULT CALLBACK MainWndProc ( HWND  HWnd,
UINT  Msg,
WPARAM  WParam,
LPARAM  LParam 
)

Definition at line 64 of file wm_paint.c.

66{
67 const char* text = "Persistent Text";
68
69 switch (Msg)
70 {
71 case WM_PAINT:
72 {
73 // determine the invalidated area of the window
74 RECT RUpdate;
75 HDC Hdc;
76 GetUpdateRect(HWnd, &RUpdate, FALSE);
77
78 // grab a handle to our window's
79 // common display device context
80 Hdc = GetDC(HWnd);
81#if 0
82 try
83#endif
84 {
85 RECT RClient;
86 GetClientRect(HWnd, &RClient);
87
88 // set the clipping region
89 IntersectClipRect(Hdc, RUpdate.left, RUpdate.top,
90 RUpdate.right, RUpdate.bottom);
91
92 // fill the client area with the background brush
93 /*HBRUSH HBrush =
94 reinterpret_cast<HBRUSH>
95 (HBRUSH)(GetClassLong(HWnd, GCL_HBRBACKGROUND)
96 );*/
97 FillRect(Hdc, &RClient, NULL);
98
99 // render the persistent text
100 SetTextColor(Hdc, PALETTERGB(0, 0, 255));
101 DrawText(Hdc, text, strlen(text), &RClient,
103 }
104#if 0
105 catch (...)
106#endif
107 {
108 // release the device context
109 ReleaseDC(HWnd, Hdc);
110
111 // validate the update area
112 ValidateRect(HWnd, &RUpdate);
113 }
114 // release the device context
115 ReleaseDC(HWnd, Hdc);
116
117 // validate the update area
118 ValidateRect(HWnd, &RUpdate);
119
120 break;
121 }
122 case WM_DESTROY:
123 {
125 return 0;
126 }
127 }
128 return DefWindowProc(HWnd, Msg, WParam, LParam);
129}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct @1627 Msg[]
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
const WCHAR * text
Definition: package.c:1799
static HDC
Definition: imagelist.c:92
#define DefWindowProc
Definition: ros2win.h:31
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define PALETTERGB(r, g, b)
Definition: wingdi.h:2942
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define WM_PAINT
Definition: winuser.h:1620
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DT_CENTER
Definition: winuser.h:527
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define DrawText
Definition: winuser.h:5771
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
#define DT_VCENTER
Definition: winuser.h:543
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)

Referenced by WinMain().

◆ WinMain()

int APIENTRY WinMain ( HINSTANCE  HInstance,
HINSTANCE  HPrevInstance,
LPTSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 25 of file wm_paint.c.

27{
28 MSG msg;
29 WNDCLASS wc;
30 memset(&wc, 0, sizeof(WNDCLASS));
31
34 wc.hInstance = HInstance;
36 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
38
39 if (RegisterClass(&wc))
40 {
41 HWND HWnd =
42 CreateWindow(WndClassName, TEXT("WM_PAINT Demo"),
45 NULL, NULL, HInstance, NULL);
46
47 if (HWnd)
48 {
49 ShowWindow(HWnd, nCmdShow);
50 UpdateWindow(HWnd);
51
52 while (GetMessage(&msg, NULL, 0, 0))
53 {
56 }
57 }
58 }
59 return 0;
60}
#define msg(x)
Definition: auth_time.c:54
#define TEXT(s)
Definition: k32.h:26
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
HBRUSH hbrBackground
Definition: winuser.h:3170
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3163
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5836
#define DispatchMessage
Definition: winuser.h:5765
#define COLOR_BTNFACE
Definition: winuser.h:928
const char * WndClassName
Definition: wm_paint.c:20
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
Definition: wm_paint.c:64
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ WndClassName

const char* WndClassName = "GMainWnd"

Definition at line 20 of file wm_paint.c.

Referenced by WinMain().