ReactOS  0.4.15-dev-1070-ge1a01de
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  {
124  PostQuitMessage(0);
125  return 0;
126  }
127  }
128  return DefWindowProc(HWnd, Msg, WParam, LParam);
129 }
HDC WINAPI GetDC(_In_opt_ HWND)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * text
Definition: package.c:1827
struct @1607 Msg[]
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define DrawText
Definition: winuser.h:5746
#define FALSE
Definition: types.h:117
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define DT_VCENTER
Definition: winuser.h:543
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define WM_PAINT
Definition: winuser.h:1602
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
#define PALETTERGB(r, g, b)
Definition: wingdi.h:2941
LONG bottom
Definition: windef.h:309
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

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"),
44  CW_USEDEFAULT, CW_USEDEFAULT, 200, 150,
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 DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5729
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
Definition: wm_paint.c:64
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CS_HREDRAW
Definition: winuser.h:648
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define WS_CAPTION
Definition: pedump.c:624
#define CS_VREDRAW
Definition: winuser.h:653
#define COLOR_BTNFACE
Definition: winuser.h:918
#define CS_DBLCLKS
Definition: winuser.h:646
LPCSTR lpszClassName
Definition: winuser.h:3147
#define LoadCursor
Definition: winuser.h:5787
UINT style
Definition: winuser.h:3138
#define TEXT(s)
Definition: k32.h:26
HINSTANCE hInstance
Definition: winuser.h:3142
const char * WndClassName
Definition: wm_paint.c:20
#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
#define RegisterClass
Definition: winuser.h:5811
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39

Variable Documentation

◆ WndClassName

const char* WndClassName = "GMainWnd"

Definition at line 20 of file wm_paint.c.

Referenced by WinMain().