ReactOS  0.4.14-dev-614-gbfd8a84
preview.c File Reference
#include "desk.h"
Include dependency graph for preview.c:

Go to the source code of this file.

Classes

struct  _PREVIEW_DATA
 

Typedefs

typedef struct _PREVIEW_DATA PREVIEW_DATA
 
typedef struct _PREVIEW_DATAPPREVIEW_DATA
 

Functions

static VOID UpdatePreviewTheme (HWND hwnd, PPREVIEW_DATA pPreviewData, COLOR_SCHEME *scheme)
 
static VOID OnCreate (HWND hwnd, PPREVIEW_DATA pPreviewData)
 
static VOID CalculateItemSize (PPREVIEW_DATA pPreviewData)
 
static VOID OnSize (INT cx, INT cy, PPREVIEW_DATA pPreviewData)
 
static VOID OnPaint (HWND hwnd, PPREVIEW_DATA pPreviewData)
 
static VOID OnLButtonDown (HWND hwnd, int xPos, int yPos, PPREVIEW_DATA pPreviewData)
 
static VOID OnDestroy (PPREVIEW_DATA pPreviewData)
 
static LRESULT CALLBACK PreviewWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL RegisterPreviewControl (IN HINSTANCE hInstance)
 
VOID UnregisterPreviewControl (IN HINSTANCE hInstance)
 

Variables

static const TCHAR szPreviewWndClass [] = TEXT("PreviewWndClass")
 

Typedef Documentation

◆ PPREVIEW_DATA

◆ PREVIEW_DATA

Function Documentation

◆ CalculateItemSize()

static VOID CalculateItemSize ( PPREVIEW_DATA  pPreviewData)
static

Definition at line 143 of file preview.c.

144 {
145  int width, height;
146 
147  /* Calculate the inactive window rectangle */
148  pPreviewData->rcInactiveFrame.left = pPreviewData->rcDesktop.left + 8;
149  pPreviewData->rcInactiveFrame.top = pPreviewData->rcDesktop.top + 8;
150  pPreviewData->rcInactiveFrame.right = pPreviewData->rcDesktop.right - 25;
151  pPreviewData->rcInactiveFrame.bottom = pPreviewData->rcDesktop.bottom - 30;
152 
153  /* Calculate the inactive caption rectangle */
154  pPreviewData->rcInactiveCaption.left = pPreviewData->rcInactiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
155  pPreviewData->rcInactiveCaption.top = pPreviewData->rcInactiveFrame.top + pPreviewData->cyEdge + pPreviewData->cySizeFrame + 1;
156  pPreviewData->rcInactiveCaption.right = pPreviewData->rcInactiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
157  pPreviewData->rcInactiveCaption.bottom = pPreviewData->rcInactiveCaption.top + pPreviewData->cyCaption - pPreviewData->cyBorder;
158 
159  /* Calculate the inactive caption buttons rectangle */
160  pPreviewData->rcInactiveCaptionButtons.left = pPreviewData->rcInactiveCaption.right - 2 - 2 - 3 * 16;
161  pPreviewData->rcInactiveCaptionButtons.top = pPreviewData->rcInactiveCaption.top + 2;
162  pPreviewData->rcInactiveCaptionButtons.right = pPreviewData->rcInactiveCaption.right - 2;
163  pPreviewData->rcInactiveCaptionButtons.bottom = pPreviewData->rcInactiveCaption.bottom - 2;
164 
165  /* Calculate the active window rectangle */
166  pPreviewData->rcActiveFrame.left = pPreviewData->rcInactiveFrame.left + 3 + pPreviewData->cySizeFrame;
167  pPreviewData->rcActiveFrame.top = pPreviewData->rcInactiveCaption.bottom + 1;
168  pPreviewData->rcActiveFrame.right = pPreviewData->rcDesktop.right - 10;
169  pPreviewData->rcActiveFrame.bottom = pPreviewData->rcDesktop.bottom - 25;
170 
171  /* Calculate the active caption rectangle */
172  pPreviewData->rcActiveCaption.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
173  pPreviewData->rcActiveCaption.top = pPreviewData->rcActiveFrame.top + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
174  pPreviewData->rcActiveCaption.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
175  pPreviewData->rcActiveCaption.bottom = pPreviewData->rcActiveCaption.top + pPreviewData->cyCaption - pPreviewData->cyBorder;
176 
177  /* Calculate the active caption buttons rectangle */
178  pPreviewData->rcActiveCaptionButtons.left = pPreviewData->rcActiveCaption.right - 2 - 2 - 3 * 16;
179  pPreviewData->rcActiveCaptionButtons.top = pPreviewData->rcActiveCaption.top + 2;
180  pPreviewData->rcActiveCaptionButtons.right = pPreviewData->rcActiveCaption.right - 2;
181  pPreviewData->rcActiveCaptionButtons.bottom = pPreviewData->rcActiveCaption.bottom - 2;
182 
183  /* Calculate the active menu bar rectangle */
184  pPreviewData->rcActiveMenuBar.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
185  pPreviewData->rcActiveMenuBar.top = pPreviewData->rcActiveCaption.bottom + 1;
186  pPreviewData->rcActiveMenuBar.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
187  pPreviewData->rcActiveMenuBar.bottom = pPreviewData->rcActiveMenuBar.top + pPreviewData->cyMenu + 1;
188 
189  /* Calculate the active client rectangle */
190  pPreviewData->rcActiveClient.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
191  pPreviewData->rcActiveClient.top = pPreviewData->rcActiveMenuBar.bottom;
192  pPreviewData->rcActiveClient.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
193  pPreviewData->rcActiveClient.bottom = pPreviewData->rcActiveFrame.bottom - pPreviewData->cyEdge - pPreviewData->cySizeFrame - 1;
194 
195  /* Calculate the active scroll rectangle */
196  pPreviewData->rcActiveScroll.left = pPreviewData->rcActiveClient.right - 2 - pPreviewData->cxScrollbar;
197  pPreviewData->rcActiveScroll.top = pPreviewData->rcActiveClient.top + 2;
198  pPreviewData->rcActiveScroll.right = pPreviewData->rcActiveClient.right - 2;
199  pPreviewData->rcActiveScroll.bottom = pPreviewData->rcActiveClient.bottom - 2;
200 
201 
202  /* Dialog window */
203  pPreviewData->rcDialogFrame.left = pPreviewData->rcActiveClient.left + 4;
204  pPreviewData->rcDialogFrame.top = (pPreviewData->rcDesktop.bottom * 60) / 100;
205  pPreviewData->rcDialogFrame.right = (pPreviewData->rcDesktop.right * 65) / 100;
206  pPreviewData->rcDialogFrame.bottom = pPreviewData->rcDesktop.bottom - 5;
207 
208  /* Calculate the dialog caption rectangle */
209  pPreviewData->rcDialogCaption.left = pPreviewData->rcDialogFrame.left + 3;
210  pPreviewData->rcDialogCaption.top = pPreviewData->rcDialogFrame.top + 3;
211  pPreviewData->rcDialogCaption.right = pPreviewData->rcDialogFrame.right - 3;
212  pPreviewData->rcDialogCaption.bottom = pPreviewData->rcDialogFrame.top + pPreviewData->cyCaption + 1 + 1;
213 
214  /* Calculate the inactive caption buttons rectangle */
215  pPreviewData->rcDialogCaptionButtons.left = pPreviewData->rcDialogCaption.right - 2 - 16;
216  pPreviewData->rcDialogCaptionButtons.top = pPreviewData->rcDialogCaption.top + 2;
217  pPreviewData->rcDialogCaptionButtons.right = pPreviewData->rcDialogCaption.right - 2;
218  pPreviewData->rcDialogCaptionButtons.bottom = pPreviewData->rcDialogCaption.bottom - 2;
219 
220  /* Calculate the dialog client rectangle */
221  pPreviewData->rcDialogClient.left = pPreviewData->rcDialogFrame.left + 3;
222  pPreviewData->rcDialogClient.top = pPreviewData->rcDialogCaption.bottom + 1;
223  pPreviewData->rcDialogClient.right = pPreviewData->rcDialogFrame.right - 3;
224  pPreviewData->rcDialogClient.bottom = pPreviewData->rcDialogFrame.bottom - 3;
225 
226  /* Calculate the dialog button rectangle */
227  width = 80;
228  height = 28;
229 
230  pPreviewData->rcDialogButton.left =
231  (pPreviewData->rcDialogClient.right + pPreviewData->rcDialogClient.left - width) / 2;
232  pPreviewData->rcDialogButton.right = pPreviewData->rcDialogButton.left + width;
233  pPreviewData->rcDialogButton.bottom = pPreviewData->rcDialogClient.bottom - 2;
234  pPreviewData->rcDialogButton.top = pPreviewData->rcDialogButton.bottom - height;
235 }
INT cySizeFrame
Definition: preview.c:28
GLint GLint GLsizei width
Definition: gl.h:1546
RECT rcActiveFrame
Definition: preview.c:40
RECT rcDialogButton
Definition: preview.c:53
RECT rcActiveCaption
Definition: preview.c:41
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
RECT rcDialogClient
Definition: preview.c:51
INT cxEdge
Definition: preview.c:25
RECT rcActiveCaptionButtons
Definition: preview.c:42
INT cyCaption
Definition: preview.c:30
RECT rcActiveMenuBar
Definition: preview.c:43
RECT rcActiveScroll
Definition: preview.c:46
RECT rcInactiveCaption
Definition: preview.c:37
INT cyEdge
Definition: preview.c:26
INT cyBorder
Definition: preview.c:31
RECT rcActiveClient
Definition: preview.c:45
RECT rcDialogCaption
Definition: preview.c:49
INT cyMenu
Definition: preview.c:32
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
RECT rcInactiveFrame
Definition: preview.c:36
RECT rcDialogFrame
Definition: preview.c:48
LONG bottom
Definition: windef.h:309
RECT rcDesktop
Definition: preview.c:35
INT cxScrollbar
Definition: preview.c:33
RECT rcInactiveCaptionButtons
Definition: preview.c:38
RECT rcDialogCaptionButtons
Definition: preview.c:50

Referenced by OnSize(), and PreviewWndProc().

◆ OnCreate()

static VOID OnCreate ( HWND  hwnd,
PPREVIEW_DATA  pPreviewData 
)
static

Definition at line 112 of file preview.c.

113 {
115 
117 
118  /* Load and modify the menu */
120  EnableMenuItem(pPreviewData->hMenu,
121  1, MF_BYPOSITION | MF_GRAYED);
122  HiliteMenuItem(hwnd, pPreviewData->hMenu,
123  2, MF_BYPOSITION | MF_HILITE);
124 
125 // GetMenuItemRect(hwnd, pPreviewData->hMenu,
126 // 2, &pPreviewData->rcSelectedMenuItem);
127 
129  AllocAndLoadString(&pPreviewData->lpAct, hApplet, IDS_ACTWIN);
134 
135  scheme = &pPreviewData->Scheme;
137 
138  UpdatePreviewTheme(hwnd, pPreviewData, scheme);
139 }
LPTSTR lpMessText
Definition: preview.c:59
HGDIOBJ WINAPI GetStockObject(_In_ int)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPTSTR lpInAct
Definition: preview.c:55
static VOID UpdatePreviewTheme(HWND hwnd, PPREVIEW_DATA pPreviewData, COLOR_SCHEME *scheme)
Definition: preview.c:72
LPTSTR lpAct
Definition: preview.c:56
HMENU hMenu
Definition: preview.c:67
DWORD scheme
HINSTANCE hApplet
Definition: access.c:17
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
#define IDS_ACTWIN
Definition: resource.h:95
#define IDR_PREVIEW_MENU
Definition: resource.h:66
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_HILITE
Definition: winuser.h:205
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI HiliteMenuItem(_In_ HWND, _In_ HMENU, _In_ UINT, _In_ UINT)
#define IDS_INACTWIN
Definition: resource.h:94
#define IDS_MESSTEXT
Definition: resource.h:98
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
LPTSTR lpMessBox
Definition: preview.c:58
#define IDS_BUTTEXT
Definition: resource.h:99
#define LoadMenu
Definition: winuser.h:5792
#define IDS_WINTEXT
Definition: resource.h:96
BOOL LoadCurrentScheme(PCOLOR_SCHEME scheme)
HFONT hClientFont
Definition: preview.c:65
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LPTSTR lpButText
Definition: preview.c:60
#define MF_GRAYED
Definition: winuser.h:129
#define IDS_MESSBOX
Definition: resource.h:97
COLOR_SCHEME Scheme
Definition: preview.c:19
LPTSTR lpWinTxt
Definition: preview.c:57

Referenced by PreviewWndProc().

◆ OnDestroy()

static VOID OnDestroy ( PPREVIEW_DATA  pPreviewData)
static

Definition at line 396 of file preview.c.

397 {
398  DeleteObject(pPreviewData->hbrScrollbar);
399  DeleteObject(pPreviewData->hbrDesktop);
400  DeleteObject(pPreviewData->hbrWindow);
401 
402  DeleteObject(pPreviewData->hCaptionFont);
403  DeleteObject(pPreviewData->hMenuFont);
404  DeleteObject(pPreviewData->hMessageFont);
405 
406  DestroyMenu(pPreviewData->hMenu);
407 
408  LocalFree((HLOCAL)pPreviewData->lpInAct);
409  LocalFree((HLOCAL)pPreviewData->lpAct);
410  LocalFree((HLOCAL)pPreviewData->lpWinTxt);
411  LocalFree((HLOCAL)pPreviewData->lpMessBox);
412  LocalFree((HLOCAL)pPreviewData->lpMessText);
413  LocalFree((HLOCAL)pPreviewData->lpButText);
414 }
LPTSTR lpMessText
Definition: preview.c:59
LPTSTR lpInAct
Definition: preview.c:55
LPTSTR lpAct
Definition: preview.c:56
HBRUSH hbrScrollbar
Definition: preview.c:21
HMENU hMenu
Definition: preview.c:67
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HFONT hCaptionFont
Definition: preview.c:62
LPTSTR lpMessBox
Definition: preview.c:58
HBRUSH hbrDesktop
Definition: preview.c:22
BOOL WINAPI DestroyMenu(_In_ HMENU)
HFONT hMessageFont
Definition: preview.c:64
HBRUSH hbrWindow
Definition: preview.c:23
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HFONT hMenuFont
Definition: preview.c:63
LPTSTR lpButText
Definition: preview.c:60
LPTSTR lpWinTxt
Definition: preview.c:57

Referenced by PreviewWndProc().

◆ OnLButtonDown()

static VOID OnLButtonDown ( HWND  hwnd,
int  xPos,
int  yPos,
PPREVIEW_DATA  pPreviewData 
)
static

Definition at line 338 of file preview.c.

339 {
341  POINT pt;
342 
343  pt.x = xPos;
344  pt.y = yPos;
345 
346  if (PtInRect(&pPreviewData->rcInactiveFrame, pt))
348 
349  if (PtInRect(&pPreviewData->rcInactiveCaption, pt))
351 
352  if (PtInRect(&pPreviewData->rcInactiveCaptionButtons, pt))
354 
355  if (PtInRect(&pPreviewData->rcActiveFrame, pt))
357 
358  if (PtInRect(&pPreviewData->rcActiveCaption, pt))
360 
361  if (PtInRect(&pPreviewData->rcActiveCaptionButtons, pt))
363 
364 // if (PtInRect(&pPreviewData->rcSelectedMenuItem, pt))
365 // type = IDX_SELECTION;
366 
367  if (PtInRect(&pPreviewData->rcActiveMenuBar, pt))
368  type = IDX_MENU;
369 
370  if (PtInRect(&pPreviewData->rcActiveClient, pt))
371  type = IDX_WINDOW;
372 
373  if (PtInRect(&pPreviewData->rcActiveScroll, pt))
375 
376  if (PtInRect(&pPreviewData->rcDialogFrame, pt))
377  type = IDX_DIALOG;
378 
379  if (PtInRect(&pPreviewData->rcDialogCaption, pt))
381 
382  if (PtInRect(&pPreviewData->rcDialogCaptionButtons, pt))
384 
385  if (PtInRect(&pPreviewData->rcDialogButton, pt))
387 
389  WM_COMMAND,
391  (LPARAM)type);
392 }
#define IDX_DIALOG
Definition: preview.h:22
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
RECT rcActiveFrame
Definition: preview.c:40
#define IDX_MENU
Definition: preview.h:16
RECT rcDialogButton
Definition: preview.c:53
#define pt(x, y)
Definition: drawing.c:79
RECT rcActiveCaption
Definition: preview.c:41
#define IDX_SCROLLBAR
Definition: preview.h:19
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define IDX_INACTIVE_BORDER
Definition: preview.h:13
#define GetWindowLongPtrW
Definition: winuser.h:4804
RECT rcActiveCaptionButtons
Definition: preview.c:42
#define IDX_3D_OBJECTS
Definition: preview.h:20
RECT rcActiveMenuBar
Definition: preview.c:43
RECT rcActiveScroll
Definition: preview.c:46
LONG_PTR LPARAM
Definition: windef.h:208
RECT rcInactiveCaption
Definition: preview.c:37
#define IDX_WINDOW
Definition: preview.h:18
RECT rcActiveClient
Definition: preview.c:45
#define IDX_ACTIVE_BORDER
Definition: preview.h:15
RECT rcDialogCaption
Definition: preview.c:49
#define WM_COMMAND
Definition: winuser.h:1722
#define IDX_ACTIVE_CAPTION
Definition: preview.h:14
HWND WINAPI GetParent(_In_ HWND)
#define IDX_DESKTOP
Definition: preview.h:11
RECT rcInactiveFrame
Definition: preview.c:36
unsigned int UINT
Definition: ndis.h:50
#define IDX_CAPTION_BUTTON
Definition: preview.h:21
RECT rcDialogFrame
Definition: preview.c:48
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define IDX_INACTIVE_CAPTION
Definition: preview.h:12
#define SendMessage
Definition: winuser.h:5818
RECT rcInactiveCaptionButtons
Definition: preview.c:38
RECT rcDialogCaptionButtons
Definition: preview.c:50
#define GWLP_ID
Definition: winuser.h:854

Referenced by PreviewWndProc().

◆ OnPaint()

static VOID OnPaint ( HWND  hwnd,
PPREVIEW_DATA  pPreviewData 
)
static

Definition at line 251 of file preview.c.

252 {
253  PAINTSTRUCT ps;
254  HFONT hOldFont;
255  HDC hdc;
256  RECT rc;
258 
259  scheme = &pPreviewData->Scheme;
260 
261  hdc = BeginPaint(hwnd, &ps);
262 
263  if (pPreviewData->hdcPreview)
264  {
265  BitBlt(hdc,0,0, pPreviewData->rcDesktop.right, pPreviewData->rcDesktop.bottom, pPreviewData->hdcPreview, 0,0, SRCCOPY);
266  EndPaint(hwnd, &ps);
267  return;
268  }
269 
270  /* Desktop */
271  FillRect(hdc, &pPreviewData->rcDesktop, pPreviewData->hbrDesktop);
272 
273  /* Inactive Window */
276  MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcInactiveCaption, pPreviewData->hCaptionFont,
277  NULL, pPreviewData->lpInAct, DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
278  MyDrawCaptionButtons(hdc, &pPreviewData->rcInactiveCaption, TRUE, pPreviewData->cyCaption - 2, scheme);
279 
280  /* Active Window */
283  MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcActiveCaption, pPreviewData->hCaptionFont,
284  NULL, pPreviewData->lpAct, DC_ACTIVE | DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
285  MyDrawCaptionButtons(hdc, &pPreviewData->rcActiveCaption, TRUE, pPreviewData->cyCaption - 2, scheme);
286 
287  /* Draw the menu bar */
288  MyDrawMenuBarTemp(hwnd, hdc, &pPreviewData->rcActiveMenuBar,
289  pPreviewData->hMenu,
290  pPreviewData->hMenuFont, scheme);
291 
292  /* Draw the client area */
293  CopyRect(&rc, &pPreviewData->rcActiveClient);
295  FillRect(hdc, &rc, pPreviewData->hbrWindow);
296 
297  /* Draw the client text */
298  CopyRect(&rc, &pPreviewData->rcActiveClient);
299  rc.left += 4;
300  rc.top += 2;
302  hOldFont = SelectObject(hdc, pPreviewData->hClientFont);
303  DrawText(hdc, pPreviewData->lpWinTxt, -1, &rc, DT_LEFT);
304  SelectObject(hdc, hOldFont);
305 
306  /* Draw the scroll bar */
307  MyDrawScrollbar(hdc, &pPreviewData->rcActiveScroll, pPreviewData->hbrScrollbar, scheme);
308 
309  /* Dialog Window */
311  SetTextColor(hdc, scheme->crColor[COLOR_WINDOW]);
312  MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcDialogCaption, pPreviewData->hCaptionFont,
313  NULL, pPreviewData->lpMessBox, DC_ACTIVE | DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
314  MyDrawCaptionButtons(hdc, &pPreviewData->rcDialogCaption, FALSE, pPreviewData->cyCaption - 2, scheme);
315 
316  /* Draw the dialog text */
317  CopyRect(&rc, &pPreviewData->rcDialogClient);
318  rc.left += 4;
319  rc.top += 2;
321  hOldFont = SelectObject(hdc, pPreviewData->hMessageFont);
322  DrawText(hdc, pPreviewData->lpMessText, -1, &rc, DT_LEFT);
323  SelectObject(hdc, hOldFont);
324 
325  /* Draw Button */
327  CopyRect(&rc, &pPreviewData->rcDialogButton);
328  SetTextColor(hdc, scheme->crColor[COLOR_BTNTEXT]);
329  hOldFont = SelectObject(hdc, pPreviewData->hMessageFont);
330  DrawText(hdc, pPreviewData->lpButText, -1, &rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
331  SelectObject(hdc, hOldFont);
332 
333  EndPaint(hwnd, &ps);
334 }
LPTSTR lpMessText
Definition: preview.c:59
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define BF_MIDDLE
Definition: winuser.h:468
#define TRUE
Definition: types.h:120
#define DFC_BUTTON
Definition: winuser.h:476
RECT rcActiveFrame
Definition: preview.c:40
LPTSTR lpInAct
Definition: preview.c:55
RECT rcDialogButton
Definition: preview.c:53
BOOL MyDrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState, COLOR_SCHEME *scheme)
Definition: draw.c:371
LPTSTR lpAct
Definition: preview.c:56
#define MY_BF_INACTIVEBORDER
Definition: draw.h:17
RECT rcActiveCaption
Definition: preview.c:41
HBRUSH hbrScrollbar
Definition: preview.c:21
static HDC
Definition: imagelist.c:92
BOOL MyDrawCaptionTemp(HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, HICON hIcon, LPCWSTR str, UINT uFlags, COLOR_SCHEME *scheme)
Definition: draw.c:457
LONG top
Definition: windef.h:307
HMENU hMenu
Definition: preview.c:67
DWORD scheme
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define COLOR_CAPTIONTEXT
Definition: winuser.h:912
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
RECT rcDialogClient
Definition: preview.c:51
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
#define COLOR_WINDOW
Definition: winuser.h:908
#define DrawText
Definition: winuser.h:5746
#define BF_ADJUST
Definition: winuser.h:470
#define DC_ICON
Definition: winuser.h:429
#define BF_RECT
Definition: winuser.h:462
#define DT_LEFT
Definition: winuser.h:534
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HFONT hCaptionFont
Definition: preview.c:62
INT cyCaption
Definition: preview.c:30
smooth NULL
Definition: ftsmooth.c:416
RECT rcActiveMenuBar
Definition: preview.c:43
RECT rcActiveScroll
Definition: preview.c:46
#define MY_BF_ACTIVEBORDER
Definition: draw.h:16
#define DT_VCENTER
Definition: winuser.h:543
#define DC_ACTIVE
Definition: winuser.h:427
RECT rcInactiveCaption
Definition: preview.c:37
#define COLOR_WINDOWTEXT
Definition: winuser.h:911
RECT rcActiveClient
Definition: preview.c:45
RECT rcDialogCaption
Definition: preview.c:49
HDC hdc
Definition: main.c:9
LPTSTR lpMessBox
Definition: preview.c:58
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:924
HBRUSH hbrDesktop
Definition: preview.c:22
BOOL MyDrawEdge(HDC hDC, LPRECT rc, UINT edge, UINT flags, COLOR_SCHEME *scheme)
Definition: draw.c:386
#define EDGE_RAISED
Definition: winuser.h:450
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define DT_SINGLELINE
Definition: winuser.h:540
HFONT hMessageFont
Definition: preview.c:64
HBRUSH hbrWindow
Definition: preview.c:23
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
RECT rcInactiveFrame
Definition: preview.c:36
HFONT hMenuFont
Definition: preview.c:63
HFONT hClientFont
Definition: preview.c:65
VOID MyDrawScrollbar(HDC hdc, LPRECT rc, HBRUSH hbrScrollbar, COLOR_SCHEME *scheme)
Definition: draw.c:424
HDC hdcPreview
Definition: preview.c:15
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
RECT rcDialogFrame
Definition: preview.c:48
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
LONG bottom
Definition: windef.h:309
LPTSTR lpButText
Definition: preview.c:60
#define DT_CENTER
Definition: winuser.h:527
RECT rcDesktop
Definition: preview.c:35
#define COLOR_BTNTEXT
Definition: winuser.h:923
#define EDGE_SUNKEN
Definition: winuser.h:451
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLOR_SCHEME Scheme
Definition: preview.c:19
LPTSTR lpWinTxt
Definition: preview.c:57
#define DC_TEXT
Definition: winuser.h:430
#define SRCCOPY
Definition: wingdi.h:332
VOID MyDrawCaptionButtons(HDC hdc, LPRECT lpRect, BOOL bMinMax, int x, COLOR_SCHEME *scheme)
Definition: draw.c:392
DWORD MyDrawMenuBarTemp(HWND Wnd, HDC DC, LPRECT Rect, HMENU Menu, HFONT Font, COLOR_SCHEME *scheme)
Definition: draw.c:527

Referenced by PreviewWndProc().

◆ OnSize()

static VOID OnSize ( INT  cx,
INT  cy,
PPREVIEW_DATA  pPreviewData 
)
static

Definition at line 239 of file preview.c.

240 {
241  /* Get Desktop rectangle */
242  pPreviewData->rcDesktop.left = 0;
243  pPreviewData->rcDesktop.top = 0;
244  pPreviewData->rcDesktop.right = cx;
245  pPreviewData->rcDesktop.bottom = cy;
246 
247  CalculateItemSize(pPreviewData);
248 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
_Out_opt_ int * cx
Definition: commctrl.h:581
LONG bottom
Definition: windef.h:309
RECT rcDesktop
Definition: preview.c:35
static VOID CalculateItemSize(PPREVIEW_DATA pPreviewData)
Definition: preview.c:143

Referenced by PreviewWndProc().

◆ PreviewWndProc()

static LRESULT CALLBACK PreviewWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 418 of file preview.c.

422 {
423  PPREVIEW_DATA pPreviewData;
424 
426 
427  switch (uMsg)
428  {
429  case WM_CREATE:
430  pPreviewData = (PPREVIEW_DATA)HeapAlloc(GetProcessHeap(),
432  sizeof(PREVIEW_DATA));
433  if (!pPreviewData)
434  return -1;
435 
436  SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pPreviewData);
437  OnCreate(hwnd, pPreviewData);
438  break;
439 
440  case WM_SIZE:
441  OnSize(LOWORD(lParam), HIWORD(lParam), pPreviewData);
442  break;
443 
444  case WM_PAINT:
445  OnPaint(hwnd, pPreviewData);
446  break;
447 
448  case WM_LBUTTONDOWN:
449  OnLButtonDown(hwnd, LOWORD(lParam), HIWORD(lParam), pPreviewData);
450  break;
451 
452  case WM_DESTROY:
453  OnDestroy(pPreviewData);
454  HeapFree(GetProcessHeap(), 0, pPreviewData);
455  break;
456 
457  case PVM_UPDATETHEME:
458  UpdatePreviewTheme(hwnd, pPreviewData, (COLOR_SCHEME *)lParam);
459  CalculateItemSize(pPreviewData);
461  break;
462 
463  case PVM_SETSIZE:
464  SchemeSetMetric(&pPreviewData->Scheme, wParam, lParam);
465  pPreviewData->cySizeFrame = pPreviewData->Scheme.ncMetrics.iBorderWidth; /* SM_CYSIZEFRAME */
466  pPreviewData->cyCaption = pPreviewData->Scheme.ncMetrics.iCaptionHeight+1; /* SM_CYCAPTION */
467  pPreviewData->cyMenu = pPreviewData->Scheme.ncMetrics.iMenuHeight -1; /* SM_CYMENU */
468  pPreviewData->cxScrollbar = pPreviewData->Scheme.ncMetrics.iScrollWidth; /* SM_CXVSCROLL */
469  pPreviewData->cyBorder = pPreviewData->Scheme.ncMetrics.iBorderWidth; /* SM_CYBORDER */
470  CalculateItemSize(pPreviewData);
472  break;
473 
474  case PVM_SETFONT:
475  {
476  PLOGFONTW plfFont;
477  HFONT* phFont;
478 
479  switch(wParam)
480  {
481  case FONT_CAPTION: phFont = &pPreviewData->hCaptionFont; break;
482  case FONT_MENU: phFont = &pPreviewData->hMenuFont; break;
483  case FONT_MESSAGE: phFont = &pPreviewData->hMessageFont; break;
484  default: return TRUE;
485  }
486 
487  plfFont = SchemeGetFont(&pPreviewData->Scheme, wParam);
488  memcpy(plfFont, (PVOID)lParam, sizeof(LOGFONTW));
489 
490  DeleteObject(*phFont);
491  *phFont = CreateFontIndirect(plfFont);
492 
494  break;
495  }
496 
497  case PVM_SETCOLOR:
498  pPreviewData->Scheme.crColor[wParam] = lParam;
499  switch(wParam)
500  {
501  case COLOR_SCROLLBAR:
502  DeleteObject(pPreviewData->hbrScrollbar);
503  pPreviewData->hbrScrollbar = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
504  break;
505  case COLOR_DESKTOP:
506  DeleteObject(pPreviewData->hbrDesktop);
507  pPreviewData->hbrDesktop = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
508  break;
509  case COLOR_WINDOW:
510  DeleteObject(pPreviewData->hbrWindow);
511  pPreviewData->hbrWindow = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
512  break;
513  }
514 
515  CalculateItemSize(pPreviewData);
517  break;
518 
519  case PVM_GETSIZE:
520  return SchemeGetMetric(&pPreviewData->Scheme, wParam);
521  case PVM_GETFONT:
522  return (LRESULT)SchemeGetFont(&pPreviewData->Scheme, wParam);
523  case PVM_GETCOLOR:
524  return pPreviewData->Scheme.crColor[wParam];
525 
526  case PVM_SET_HDC_PREVIEW:
527  pPreviewData->hdcPreview = (HDC)lParam;
529  break;
530 
531  default:
532  return DefWindowProc(hwnd, uMsg, wParam, lParam);
533  }
534  return FALSE;
535 }
struct _PREVIEW_DATA PREVIEW_DATA
NONCLIENTMETRICSW ncMetrics
Definition: appearance.h:59
INT cySizeFrame
Definition: preview.c:28
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define PVM_SETSIZE
Definition: preview.h:26
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
static VOID UpdatePreviewTheme(HWND hwnd, PPREVIEW_DATA pPreviewData, COLOR_SCHEME *scheme)
Definition: preview.c:72
#define PVM_SETFONT
Definition: preview.h:28
static VOID OnCreate(HWND hwnd, PPREVIEW_DATA pPreviewData)
Definition: preview.c:112
HBRUSH hbrScrollbar
Definition: preview.c:21
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PVM_SETCOLOR
Definition: preview.h:30
#define COLOR_DESKTOP
Definition: winuser.h:904
#define COLOR_WINDOW
Definition: winuser.h:908
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
int SchemeGetMetric(COLOR_SCHEME *scheme, int id)
COLORREF crColor[NUM_COLORS]
Definition: appearance.h:61
#define PVM_GETSIZE
Definition: preview.h:27
static VOID OnPaint(HWND hwnd, PPREVIEW_DATA pPreviewData)
Definition: preview.c:251
static VOID OnSize(INT cx, INT cy, PPREVIEW_DATA pPreviewData)
Definition: preview.c:239
#define COLOR_SCROLLBAR
Definition: winuser.h:902
HFONT hCaptionFont
Definition: preview.c:62
#define GWLP_USERDATA
Definition: treelist.c:63
#define PVM_SET_HDC_PREVIEW
Definition: preview.h:32
INT cyCaption
Definition: preview.c:30
smooth NULL
Definition: ftsmooth.c:416
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
static VOID OnLButtonDown(HWND hwnd, int xPos, int yPos, PPREVIEW_DATA pPreviewData)
Definition: preview.c:338
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define WM_SIZE
Definition: winuser.h:1593
INT cyBorder
Definition: preview.c:31
#define PVM_GETFONT
Definition: preview.h:29
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define FONT_CAPTION
Definition: appearance.h:18
#define PVM_UPDATETHEME
Definition: preview.h:33
#define WM_PAINT
Definition: winuser.h:1602
#define PVM_GETCOLOR
Definition: preview.h:31
static VOID OnDestroy(PPREVIEW_DATA pPreviewData)
Definition: preview.c:396
HBRUSH hbrDesktop
Definition: preview.c:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _PREVIEW_DATA * PPREVIEW_DATA
INT cyMenu
Definition: preview.c:32
#define FONT_MENU
Definition: appearance.h:20
HFONT hMessageFont
Definition: preview.c:64
HBRUSH hbrWindow
Definition: preview.c:23
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
PLOGFONTW SchemeGetFont(COLOR_SCHEME *scheme, int id)
#define CreateFontIndirect
Definition: wingdi.h:4443
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HFONT hMenuFont
Definition: preview.c:63
HDC hdcPreview
Definition: preview.c:15
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define WM_CREATE
Definition: winuser.h:1590
VOID SchemeSetMetric(COLOR_SCHEME *scheme, int id, int value)
#define HIWORD(l)
Definition: typedefs.h:246
INT cxScrollbar
Definition: preview.c:33
static VOID CalculateItemSize(PPREVIEW_DATA pPreviewData)
Definition: preview.c:143
#define GetWindowLongPtr
Definition: treelist.c:73
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
COLOR_SCHEME Scheme
Definition: preview.c:19
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:402
#define FONT_MESSAGE
Definition: appearance.h:22

Referenced by RegisterPreviewControl().

◆ RegisterPreviewControl()

BOOL RegisterPreviewControl ( IN HINSTANCE  hInstance)

Definition at line 539 of file preview.c.

540 {
541  WNDCLASSEX wc = {0};
542 
543  wc.cbSize = sizeof(wc);
545  wc.hInstance = hInstance;
547  wc.hbrBackground = (HBRUSH)NULL;
549 
550  return RegisterClassEx(&wc) != (ATOM)0;
551 }
#define RegisterClassEx
Definition: winuser.h:5812
HCURSOR hCursor
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3178
LPCSTR lpszClassName
Definition: winuser.h:3186
WORD ATOM
Definition: dimm.idl:113
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3181
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3176
HBRUSH hbrBackground
Definition: winuser.h:3184
static LRESULT CALLBACK PreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: preview.c:418
#define LoadCursor
Definition: winuser.h:5787
static const TCHAR szPreviewWndClass[]
Definition: preview.c:11
#define IDC_ARROW
Definition: winuser.h:682

Referenced by DllMain().

◆ UnregisterPreviewControl()

VOID UnregisterPreviewControl ( IN HINSTANCE  hInstance)

Definition at line 555 of file preview.c.

556 {
558 }
HINSTANCE hInstance
Definition: charmap.c:20
static const TCHAR szPreviewWndClass[]
Definition: preview.c:11
#define UnregisterClass
Definition: winuser.h:5836

Referenced by DllMain().

◆ UpdatePreviewTheme()

static VOID UpdatePreviewTheme ( HWND  hwnd,
PPREVIEW_DATA  pPreviewData,
COLOR_SCHEME scheme 
)
static

Definition at line 72 of file preview.c.

73 {
74  if (pPreviewData->hbrScrollbar != NULL)
75  DeleteObject(pPreviewData->hbrScrollbar);
76  pPreviewData->hbrScrollbar = CreateSolidBrush(scheme->crColor[COLOR_SCROLLBAR]);
77  if (pPreviewData->hbrDesktop != NULL)
78  DeleteObject(pPreviewData->hbrDesktop);
79 
80  pPreviewData->hbrDesktop = CreateSolidBrush(scheme->crColor[COLOR_DESKTOP]);
81  if (pPreviewData->hbrWindow != NULL)
82  DeleteObject(pPreviewData->hbrWindow);
83  pPreviewData->hbrWindow = CreateSolidBrush(scheme->crColor[COLOR_WINDOW]);
84 
85  pPreviewData->cxEdge = 2; /* SM_CXEDGE */
86  pPreviewData->cyEdge = 2; /* SM_CYEDGE */
87 
88  pPreviewData->cySizeFrame = scheme->ncMetrics.iBorderWidth; /* SM_CYSIZEFRAME */
89 
90  pPreviewData->cyCaption = scheme->ncMetrics.iCaptionHeight+1; /* SM_CYCAPTION */
91  pPreviewData->cyMenu = scheme->ncMetrics.iMenuHeight -1; /* SM_CYMENU */
92  pPreviewData->cxScrollbar = scheme->ncMetrics.iScrollWidth; /* SM_CXVSCROLL */
93  pPreviewData->cyBorder = scheme->ncMetrics.iBorderWidth; /* SM_CYBORDER */
94 
95  if (pPreviewData->hCaptionFont != NULL)
96  DeleteObject(pPreviewData->hCaptionFont);
97  pPreviewData->hCaptionFont = CreateFontIndirect(&scheme->ncMetrics.lfCaptionFont);
98 
99  if (pPreviewData->hMenuFont != NULL)
100  DeleteObject(pPreviewData->hMenuFont);
101  pPreviewData->hMenuFont = CreateFontIndirect(&scheme->ncMetrics.lfMenuFont);
102 
103  if (pPreviewData->hMessageFont != NULL)
104  DeleteObject(pPreviewData->hMessageFont);
105  pPreviewData->hMessageFont = CreateFontIndirect(&scheme->ncMetrics.lfMessageFont);
106 
107  pPreviewData->Scheme = *scheme;
109 }
INT cySizeFrame
Definition: preview.c:28
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HBRUSH hbrScrollbar
Definition: preview.c:21
DWORD scheme
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define COLOR_DESKTOP
Definition: winuser.h:904
#define COLOR_WINDOW
Definition: winuser.h:908
INT cxEdge
Definition: preview.c:25
#define COLOR_SCROLLBAR
Definition: winuser.h:902
HFONT hCaptionFont
Definition: preview.c:62
INT cyCaption
Definition: preview.c:30
smooth NULL
Definition: ftsmooth.c:416
INT cyEdge
Definition: preview.c:26
INT cyBorder
Definition: preview.c:31
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HBRUSH hbrDesktop
Definition: preview.c:22
INT cyMenu
Definition: preview.c:32
HFONT hMessageFont
Definition: preview.c:64
HBRUSH hbrWindow
Definition: preview.c:23
#define CreateFontIndirect
Definition: wingdi.h:4443
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HFONT hMenuFont
Definition: preview.c:63
INT cxScrollbar
Definition: preview.c:33
COLOR_SCHEME Scheme
Definition: preview.c:19

Referenced by OnCreate(), and PreviewWndProc().

Variable Documentation

◆ szPreviewWndClass

const TCHAR szPreviewWndClass[] = TEXT("PreviewWndClass")
static

Definition at line 11 of file preview.c.

Referenced by RegisterPreviewControl(), and UnregisterPreviewControl().