ReactOS  0.4.14-dev-323-g6fe6a88
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)
44  , m_hbitmap(NULL)
45  , m_oldbitmap(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,
79  WS_POPUP,
80  x, y,
82  NULL, NULL,
84  (LPVOID)this);
85  }
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HGDIOBJ m_oldbitmap
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
long LONG
Definition: pedump.c:60
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
static LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LPCWSTR lpszClassName
Definition: winuser.h:3200
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
static HINSTANCE hDllInstance
Definition: clb.c:30
int WINAPI GetSystemMetrics(_In_ int)
DWORD biSizeImage
Definition: amvideo.idl:36
HINSTANCE hInstance
Definition: winuser.h:3195
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
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)
#define WS_EX_TOPMOST
Definition: pedump.c:647
HCURSOR hCursor
Definition: winuser.h:3197
HBITMAP m_hbitmap
#define LoadCursor
Definition: winuser.h:5713
WNDPROC lpfnWndProc
Definition: winuser.h:3192
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
BITMAPINFO m_bi
#define WS_POPUP
Definition: pedump.c:616
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDC_ARROW
Definition: winuser.h:682
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:34

◆ ~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  }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HGDIOBJ m_oldbitmap
BOOL WINAPI DestroyWindow(_In_ HWND)
static HINSTANCE hDllInstance
Definition: clb.c:30
static const WCHAR L[]
Definition: oid.c:1250
HBITMAP m_hbitmap

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 PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
HDC hdc
Definition: main.c:9
#define SRCCOPY
Definition: wingdi.h:332

◆ 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  }
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HGDIOBJ m_oldbitmap
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:652
HBITMAP m_hbitmap
#define SRCCOPY
Definition: wingdi.h:332

Referenced by Init().

◆ Init()

void CDimmedWindow::Init ( )
inline

Definition at line 120 of file dimmedwindow.cpp.

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

◆ 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  }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
eMaj lines
Definition: tritemp.h:206
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned char UCHAR
Definition: xmlstorage.h:181
HBITMAP m_hbitmap
BITMAPINFO m_bi
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)
#define DIB_RGB_COLORS
Definition: wingdi.h:366
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 
107  while (IsWindow(m_hwnd) && !IsWindowVisible(m_hwnd))
108  {
109  while (::PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
110  {
113 
114  if (IsWindowVisible(m_hwnd))
115  break;
116  }
117  }
118  }
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5731
BOOL WINAPI IsWindow(_In_opt_ HWND)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define PM_REMOVE
Definition: winuser.h:1182

◆ 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  {
216  CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
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  {
231  CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
233  info->Init();
234  }
235  else if (wParam == FADE_TIMER_ID)
236  {
237  CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
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 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4730
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_TIMER
Definition: winuser.h:1724
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define WM_PAINT
Definition: winuser.h:1602
#define FADE_TIMER_ID
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
LPVOID lpCreateParams
Definition: winuser.h:2914
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowLongPtrW
Definition: winuser.h:5247
#define INIT_TIMER_ID
LPARAM lParam
Definition: combotst.c:139

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: