ReactOS  0.4.13-dev-563-g0561610
wm_erasebkgnd.cpp File Reference
#include <windows.h>
Include dependency graph for wm_erasebkgnd.cpp:

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

HINSTANCE HInst
 
HINSTANCE HPrevInst
 
TCHARcmdline
 
const charWndClassName = "GMainWnd"
 
HWND HStatic
 
HDC HMemDC
 
HBITMAP HBmp
 
HBITMAP HOldBmp
 
const charfilename = "BACKBITMAP.BMP"
 

Function Documentation

◆ MainWndProc()

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

Definition at line 90 of file wm_erasebkgnd.cpp.

92 {
93  switch (Msg)
94  {
95  case WM_CREATE:
96  {
97  HStatic =
98  CreateWindow(TEXT("STATIC"), TEXT("Static Text"),
100  10, 20, 175, 30,
101  HWnd, NULL, HInst, NULL);
102 
103  // create a memory DC compatible with the screen
105  if (HMemDC)
106  {
107  // load a DDB from file
108  HBmp = static_cast<HBITMAP>(
110  0, 0, LR_LOADFROMFILE)
111  );
112  if (HBmp)
113  {
114  // associate the DDB with the memory DC
115  HOldBmp = static_cast<HBITMAP>(
117  );
118  }
119  }
120  }
121  case WM_CTLCOLORSTATIC:
122  {
123  if (reinterpret_cast<HWND>(LParam) == HStatic)
124  {
125  HDC HStaticDC = reinterpret_cast<HDC>(WParam);
126  SetBkMode(HStaticDC, TRANSPARENT);
127 
128  return reinterpret_cast<LRESULT>(
130  );
131  }
132  break;
133  }
134  case WM_ERASEBKGND:
135  {
136  BITMAP bmp;
137  if (GetObject(HBmp, sizeof(BITMAP), &bmp))
138  {
139  RECT RClient;
140  GetClientRect(HWnd, &RClient);
141 
142  HDC Hdc = reinterpret_cast<HDC>(WParam);
144 
145  //
146  // TODO: add palette handling code for
147  // palettized displays (see Chapter 9)...
148  //
149 
150  // render the background image
151  StretchBlt(Hdc, 0, 0,
152  RClient.right - RClient.left,
153  RClient.bottom - RClient.top,
154  HMemDC, 0, 0, bmp.bmWidth, bmp.bmHeight,
155  SRCCOPY);
156  return TRUE;
157  }
158  break;
159  }
160  case WM_DESTROY:
161  {
162  if (HBmp)
163  {
164  // free the bitmap
166  }
167  // free the memory DC
168  DeleteDC(HMemDC);
169 
170  PostQuitMessage(0);
171  return 0;
172  }
173  }
174  return DefWindowProc(HWnd, Msg, WParam, LParam);
175 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRUE
Definition: types.h:120
#define CreateWindow
Definition: winuser.h:5620
HINSTANCE HInst
#define LR_LOADFROMFILE
Definition: winuser.h:1082
#define NULL_BRUSH
Definition: wingdi.h:900
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
#define COLORONCOLOR
Definition: wingdi.h:953
const char * filename
Definition: ioapi.h:135
LONG right
Definition: windef.h:293
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define TRANSPARENT
Definition: wingdi.h:949
smooth NULL
Definition: ftsmooth.c:416
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define SS_CENTER
Definition: pedump.c:693
#define GetObject
Definition: wingdi.h:4446
BITMAP bmp
Definition: alphablend.c:62
struct @1574 Msg[]
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1324
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define TEXT(s)
Definition: k32.h:26
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
#define IMAGE_BITMAP
Definition: winuser.h:211
HDC HMemDC
#define WM_CREATE
Definition: winuser.h:1590
HWND HStatic
LONG bottom
Definition: windef.h:294
#define LoadImage
Definition: winuser.h:5681
HBITMAP HOldBmp
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WS_VISIBLE
Definition: pedump.c:620
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SRCCOPY
Definition: wingdi.h:332
HBITMAP HBmp

Referenced by WinMain().

◆ WinMain()

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

Definition at line 38 of file wm_erasebkgnd.cpp.

40 {
41  HInst = HInstance;
42  HPrevInst = HPrevInstance;
43  cmdline = lpCmdLine;
44 
45  WNDCLASS wc;
46  memset(&wc, 0, sizeof(WNDCLASS));
47 
50  wc.hInstance = HInstance;
52  wc.hbrBackground =
53  reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1);
55 
56  if (RegisterClass(&wc))
57  {
58  HWND HWnd =
60  TEXT("WM_ERASEBKGND Demo"),
63  CW_USEDEFAULT, CW_USEDEFAULT, 205, 85,
64  NULL, NULL, HInstance, NULL);
65 
66  if (HWnd)
67  {
68  ShowWindow(HWnd, nCmdShow);
69  UpdateWindow(HWnd);
70 
71  MSG msg;
72  while (GetMessage(&msg, NULL, 0, 0))
73  {
76  }
77  }
78  }
79  return 0;
80 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define CreateWindow
Definition: winuser.h:5620
HINSTANCE HInst
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
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:3123
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HCURSOR hCursor
Definition: winuser.h:3122
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define WS_CAPTION
Definition: pedump.c:624
const char * WndClassName
#define CS_VREDRAW
Definition: winuser.h:653
HINSTANCE HPrevInst
#define COLOR_BTNFACE
Definition: winuser.h:918
#define CS_DBLCLKS
Definition: winuser.h:646
LPCSTR lpszClassName
Definition: winuser.h:3125
#define LoadCursor
Definition: winuser.h:5678
UINT style
Definition: winuser.h:3116
#define TEXT(s)
Definition: k32.h:26
HINSTANCE hInstance
Definition: winuser.h:3120
#define GetMessage
Definition: winuser.h:5656
WNDPROC lpfnWndProc
Definition: winuser.h:3117
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
TCHAR * cmdline
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define RegisterClass
Definition: winuser.h:5702
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39

Variable Documentation

◆ cmdline

TCHAR* cmdline

Definition at line 32 of file wm_erasebkgnd.cpp.

Referenced by WinMain().

◆ filename

const char* filename = "BACKBITMAP.BMP"

Definition at line 88 of file wm_erasebkgnd.cpp.

◆ HBmp

HBITMAP HBmp

Definition at line 87 of file wm_erasebkgnd.cpp.

Referenced by MainWndProc().

◆ HInst

HINSTANCE HInst

Definition at line 30 of file wm_erasebkgnd.cpp.

Referenced by MainWndProc(), and WinMain().

◆ HMemDC

HDC HMemDC

Definition at line 86 of file wm_erasebkgnd.cpp.

Referenced by MainWndProc().

◆ HOldBmp

HBITMAP HOldBmp

Definition at line 87 of file wm_erasebkgnd.cpp.

Referenced by MainWndProc().

◆ HPrevInst

HINSTANCE HPrevInst

Definition at line 31 of file wm_erasebkgnd.cpp.

Referenced by WinMain().

◆ HStatic

HWND HStatic

Definition at line 85 of file wm_erasebkgnd.cpp.

Referenced by MainWndProc().

◆ WndClassName

const char* WndClassName = "GMainWnd"

Definition at line 33 of file wm_erasebkgnd.cpp.

Referenced by WinMain().