ReactOS 0.4.15-dev-8191-gbc6c731
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 }
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
169
171 return 0;
172 }
173 }
174 return DefWindowProc(HWnd, Msg, WParam, LParam);
175}
struct @1641 Msg[]
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
pKey DeleteObject()
const char * filename
Definition: ioapi.h:137
#define TEXT(s)
Definition: k32.h:26
BITMAP bmp
Definition: alphablend.c:62
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define SS_CENTER
Definition: pedump.c:693
#define DefWindowProc
Definition: ros2win.h:31
Definition: bl.h:1331
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG_PTR LRESULT
Definition: windef.h:209
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define COLORONCOLOR
Definition: wingdi.h:954
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
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)
#define SRCCOPY
Definition: wingdi.h:333
#define NULL_BRUSH
Definition: wingdi.h:901
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1366
#define WM_ERASEBKGND
Definition: winuser.h:1625
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_LOADFROMFILE
Definition: winuser.h:1092
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define CreateWindow
Definition: winuser.h:5763
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LoadImage
Definition: winuser.h:5824
#define WM_DESTROY
Definition: winuser.h:1609
HBITMAP HBmp
HWND HStatic
HDC HMemDC
HINSTANCE HInst
HBITMAP HOldBmp

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"),
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 msg(x)
Definition: auth_time.c:54
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#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 GetMessage
Definition: winuser.h:5799
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5821
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5845
#define DispatchMessage
Definition: winuser.h:5774
#define COLOR_BTNFACE
Definition: winuser.h:928
const char * WndClassName
HINSTANCE HPrevInst
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
TCHAR * cmdline

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().