ReactOS 0.4.15-dev-5667-ged97270
CDimmedWindow Class Reference
Inheritance diagram for CDimmedWindow:
Collaboration diagram for CDimmedWindow:

Public Member Functions

 CDimmedWindow ()
 
 ~CDimmedWindow ()
 
void WaitForInit ()
 
void Init ()
 
void Capture ()
 
bool Step ()
 
void Blt (HDC hdc)
 
HWND Wnd ()
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Static Private Member Functions

static LRESULT WINAPI WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Private Attributes

HWND m_hwnd
 
HDC m_hdc
 
HBITMAP m_hbitmap
 
HGDIOBJ m_oldbitmap
 
LONG m_width
 
LONG m_height
 
BITMAPINFO m_bi
 
UCHARm_bytes
 
int m_step
 

Additional Inherited Members

- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Private Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Private Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Detailed Description

Definition at line 23 of file dimmedwindow.cpp.

Constructor & Destructor Documentation

◆ CDimmedWindow()

CDimmedWindow::CDimmedWindow ( )
inline

Definition at line 41 of file dimmedwindow.cpp.

42 : m_hwnd(NULL)
43 , m_hdc(NULL)
46 , m_width(0)
47 , m_height(0)
48 , m_bytes(NULL)
49 , m_step(0)
50 {
51 WNDCLASSEXW wndclass = {sizeof(wndclass)};
52 wndclass.lpfnWndProc = WndProc;
53 wndclass.hInstance = hDllInstance;
54 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
55 wndclass.lpszClassName = L"DimmedWindowClass";
56
57 if (!RegisterClassExW(&wndclass))
58 return;
59
62
63 memset(&m_bi, 0, sizeof(m_bi));
64 m_bi.bmiHeader.biSize = sizeof(m_bi);
71 m_bytes = new UCHAR[m_width * 4 * m_height];
72
75
77 L"DimmedWindowClass",
78 NULL,
80 x, y,
82 NULL, NULL,
84 (LPVOID)this);
85 }
BITMAPINFO m_bi
static LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HBITMAP m_hbitmap
HGDIOBJ m_oldbitmap
static HINSTANCE hDllInstance
Definition: clb.c:30
#define NULL
Definition: types.h:112
#define BI_RGB
Definition: precomp.h:47
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define L(x)
Definition: ntvdm.h:50
#define WS_POPUP
Definition: pedump.c:616
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define memset(x, y, z)
Definition: compat.h:39
LPCWSTR lpszClassName
Definition: winuser.h:3216
WNDPROC lpfnWndProc
Definition: winuser.h:3208
HCURSOR hCursor
Definition: winuser.h:3213
HINSTANCE hInstance
Definition: winuser.h:3211
USHORT biBitCount
Definition: precomp.h:37
ULONG biCompression
Definition: precomp.h:38
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1033
#define IDC_ARROW
Definition: winuser.h:682
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1032
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LoadCursor
Definition: winuser.h:5802
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1030
int WINAPI GetSystemMetrics(_In_ int)
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1031
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ ~CDimmedWindow()

CDimmedWindow::~CDimmedWindow ( )
inline

Definition at line 87 of file dimmedwindow.cpp.

88 {
89 if (m_hwnd)
91 UnregisterClassW(L"DimmedWindowClass", hDllInstance);
92 if (m_oldbitmap)
94 if (m_hbitmap)
96 if (m_hdc)
98 if (m_bytes)
99 delete[] m_bytes;
100 }
pKey DeleteObject()
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)

Member Function Documentation

◆ Blt()

void CDimmedWindow::Blt ( HDC  hdc)
inline

Definition at line 183 of file dimmedwindow.cpp.

184 {
185 BitBlt(hdc, 0, 0, m_width, m_height, m_hdc, 0, 0, SRCCOPY);
186 }
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
HDC hdc
Definition: main.c:9
#define SRCCOPY
Definition: wingdi.h:333

◆ Capture()

void CDimmedWindow::Capture ( )
inline

Definition at line 131 of file dimmedwindow.cpp.

132 {
133 HWND desktopWnd = GetDesktopWindow();
134 HDC desktopDC = GetDC(desktopWnd);
135
136 m_hdc = CreateCompatibleDC(desktopDC);
137
140 BitBlt(m_hdc, 0, 0, m_width, m_height, desktopDC, 0, 0, SRCCOPY);
141
142 ReleaseDC(desktopWnd, desktopDC);
143 }
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by Init().

◆ Init()

void CDimmedWindow::Init ( )
inline

Definition at line 120 of file dimmedwindow.cpp.

121 {
122 Capture();
123
127
129 }
#define FADE_TIMER_ID
#define FALSE
Definition: types.h:117
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SW_SHOW
Definition: winuser.h:769

◆ Step()

bool CDimmedWindow::Step ( )
inline

Definition at line 145 of file dimmedwindow.cpp.

146 {
147 // Stop after 10 steps
148 if (m_step++ > 10 || !m_bytes)
149 return false;
150
152 if (lines)
153 {
154 for (int xh = 0; xh < m_height; ++xh)
155 {
156 int h = m_width * 4 * xh;
157 for (int w = 0; w < m_width; ++w)
158 {
159 UCHAR b = m_bytes[(h + w * 4) + 0];
160 UCHAR g = m_bytes[(h + w * 4) + 1];
161 UCHAR r = m_bytes[(h + w * 4) + 2];
162
163 // Standard formula to convert a color.
164 int gray = (r * 30 + g * 59 + b * 11) / 100;
165 if (gray < 0)
166 gray = 0;
167
168 // Do not fade too fast.
169 r = (r*2 + gray) / 3;
170 g = (g*2 + gray) / 3;
171 b = (b*2 + gray) / 3;
172
173 m_bytes[(h + w * 4) + 0] = b;
174 m_bytes[(h + w * 4) + 1] = g;
175 m_bytes[(h + w * 4) + 2] = r;
176 }
177 }
179 }
180 return true;
181 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
eMaj lines
Definition: tritemp.h:206
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)

◆ WaitForInit()

void CDimmedWindow::WaitForInit ( )
inline

Definition at line 103 of file dimmedwindow.cpp.

104 {
105 MSG msg;
106
108 {
109 while (::PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
110 {
113
115 break;
116 }
117 }
118 }
#define msg(x)
Definition: auth_time.c:54
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PM_REMOVE
Definition: winuser.h:1186
#define PeekMessage
Definition: winuser.h:5820
#define DispatchMessage
Definition: winuser.h:5755
BOOL WINAPI IsWindowVisible(_In_ HWND)

◆ Wnd()

HWND CDimmedWindow::Wnd ( )
inline

Definition at line 188 of file dimmedwindow.cpp.

189 {
190 return m_hwnd;
191 }

◆ WndProc()

LRESULT WINAPI CDimmedWindow::WndProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 201 of file dimmedwindow.cpp.

202{
203 switch (uMsg)
204 {
205 case WM_NCCREATE:
206 {
207 LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
208 CDimmedWindow* info = static_cast<CDimmedWindow*>(lpcs->lpCreateParams);
211 break;
212 }
213
214 case WM_PAINT:
215 {
217 if (info)
218 {
219 PAINTSTRUCT ps;
220 BeginPaint(hWnd, &ps);
221 info->Blt(ps.hdc);
222 EndPaint(hWnd, &ps);
223 }
224 return 0;
225 }
226
227 case WM_TIMER:
228 {
229 if (wParam == INIT_TIMER_ID)
230 {
233 info->Init();
234 }
235 else if (wParam == FADE_TIMER_ID)
236 {
238 if (info && info->Step())
240 else
242 }
243 return 0;
244 }
245
246 default:
247 break;
248 }
249
250 return DefWindowProc(hWnd, uMsg, wParam, lParam);
251}
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define INIT_TIMER_ID
#define TRUE
Definition: types.h:120
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define DefWindowProc
Definition: ros2win.h:31
LPVOID lpCreateParams
Definition: winuser.h:2930
#define GWLP_USERDATA
Definition: treelist.c:63
#define WM_PAINT
Definition: winuser.h:1610
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define WM_NCCREATE
Definition: winuser.h:1673
#define WM_TIMER
Definition: winuser.h:1732
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
Definition: winuser.h:5336

Referenced by CDimmedWindow().

Member Data Documentation

◆ m_bi

BITMAPINFO CDimmedWindow::m_bi
private

Definition at line 34 of file dimmedwindow.cpp.

Referenced by CDimmedWindow(), and Step().

◆ m_bytes

UCHAR* CDimmedWindow::m_bytes
private

Definition at line 35 of file dimmedwindow.cpp.

Referenced by CDimmedWindow(), Step(), and ~CDimmedWindow().

◆ m_hbitmap

HBITMAP CDimmedWindow::m_hbitmap
private

Definition at line 30 of file dimmedwindow.cpp.

Referenced by Capture(), Step(), and ~CDimmedWindow().

◆ m_hdc

HDC CDimmedWindow::m_hdc
private

Definition at line 29 of file dimmedwindow.cpp.

Referenced by Blt(), Capture(), Step(), and ~CDimmedWindow().

◆ m_height

LONG CDimmedWindow::m_height
private

Definition at line 33 of file dimmedwindow.cpp.

Referenced by Blt(), Capture(), CDimmedWindow(), and Step().

◆ m_hwnd

HWND CDimmedWindow::m_hwnd
private

Definition at line 28 of file dimmedwindow.cpp.

Referenced by CDimmedWindow(), Init(), WaitForInit(), Wnd(), and ~CDimmedWindow().

◆ m_oldbitmap

HGDIOBJ CDimmedWindow::m_oldbitmap
private

Definition at line 31 of file dimmedwindow.cpp.

Referenced by Capture(), and ~CDimmedWindow().

◆ m_step

int CDimmedWindow::m_step
private

Definition at line 36 of file dimmedwindow.cpp.

Referenced by Step().

◆ m_width

LONG CDimmedWindow::m_width
private

Definition at line 32 of file dimmedwindow.cpp.

Referenced by Blt(), Capture(), CDimmedWindow(), and Step().


The documentation for this class was generated from the following file: