ReactOS 0.4.15-dev-5666-gc548b97
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}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
RECT rcActiveFrame
Definition: preview.c:40
RECT rcInactiveFrame
Definition: preview.c:36
RECT rcActiveClient
Definition: preview.c:45
RECT rcDialogClient
Definition: preview.c:51
RECT rcActiveCaptionButtons
Definition: preview.c:42
RECT rcInactiveCaption
Definition: preview.c:37
RECT rcActiveMenuBar
Definition: preview.c:43
RECT rcInactiveCaptionButtons
Definition: preview.c:38
INT cyCaption
Definition: preview.c:30
RECT rcActiveCaption
Definition: preview.c:41
INT cxScrollbar
Definition: preview.c:33
RECT rcActiveScroll
Definition: preview.c:46
RECT rcDialogFrame
Definition: preview.c:48
INT cyEdge
Definition: preview.c:26
INT cyMenu
Definition: preview.c:32
INT cyBorder
Definition: preview.c:31
INT cxEdge
Definition: preview.c:25
INT cySizeFrame
Definition: preview.c:28
RECT rcDialogButton
Definition: preview.c:53
RECT rcDesktop
Definition: preview.c:35
RECT rcDialogCaptionButtons
Definition: preview.c:50
RECT rcDialogCaption
Definition: preview.c:49
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306

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,
122 HiliteMenuItem(hwnd, pPreviewData->hMenu,
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}
BOOL LoadCurrentScheme(PCOLOR_SCHEME scheme)
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
HINSTANCE hApplet
Definition: access.c:17
#define IDS_BUTTEXT
Definition: resource.h:110
#define IDS_WINTEXT
Definition: resource.h:107
#define IDS_INACTWIN
Definition: resource.h:105
#define IDS_ACTWIN
Definition: resource.h:106
#define IDR_PREVIEW_MENU
Definition: resource.h:77
#define IDS_MESSTEXT
Definition: resource.h:109
#define IDS_MESSBOX
Definition: resource.h:108
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static VOID UpdatePreviewTheme(HWND hwnd, PPREVIEW_DATA pPreviewData, COLOR_SCHEME *scheme)
Definition: preview.c:72
DWORD scheme
COLOR_SCHEME Scheme
Definition: preview.c:19
HMENU hMenu
Definition: preview.c:67
LPTSTR lpMessBox
Definition: preview.c:58
LPTSTR lpButText
Definition: preview.c:60
HFONT hClientFont
Definition: preview.c:65
LPTSTR lpAct
Definition: preview.c:56
LPTSTR lpInAct
Definition: preview.c:55
LPTSTR lpMessText
Definition: preview.c:59
LPTSTR lpWinTxt
Definition: preview.c:57
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
BOOL WINAPI HiliteMenuItem(_In_ HWND, _In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_BYPOSITION
Definition: winuser.h:203
#define LoadMenu
Definition: winuser.h:5807
#define MF_HILITE
Definition: winuser.h:205
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define MF_GRAYED
Definition: winuser.h:129

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}
pKey DeleteObject()
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HFONT hMenuFont
Definition: preview.c:63
HBRUSH hbrScrollbar
Definition: preview.c:21
HBRUSH hbrWindow
Definition: preview.c:23
HFONT hMessageFont
Definition: preview.c:64
HFONT hCaptionFont
Definition: preview.c:62
HBRUSH hbrDesktop
Definition: preview.c:22
BOOL WINAPI DestroyMenu(_In_ HMENU)

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))
372
373 if (PtInRect(&pPreviewData->rcActiveScroll, pt))
375
376 if (PtInRect(&pPreviewData->rcDialogFrame, pt))
378
379 if (PtInRect(&pPreviewData->rcDialogCaption, pt))
381
382 if (PtInRect(&pPreviewData->rcDialogCaptionButtons, pt))
384
385 if (PtInRect(&pPreviewData->rcDialogButton, pt))
387
391 (LPARAM)type);
392}
#define pt(x, y)
Definition: drawing.c:79
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int UINT
Definition: ndis.h:50
#define IDX_INACTIVE_BORDER
Definition: preview.h:13
#define IDX_ACTIVE_BORDER
Definition: preview.h:15
#define IDX_INACTIVE_CAPTION
Definition: preview.h:12
#define IDX_WINDOW
Definition: preview.h:18
#define IDX_SCROLLBAR
Definition: preview.h:19
#define IDX_MENU
Definition: preview.h:16
#define IDX_DIALOG
Definition: preview.h:22
#define IDX_DESKTOP
Definition: preview.h:11
#define IDX_3D_OBJECTS
Definition: preview.h:20
#define IDX_ACTIVE_CAPTION
Definition: preview.h:14
#define IDX_CAPTION_BUTTON
Definition: preview.h:21
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEWPARAM(l, h)
Definition: winuser.h:3999
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define WM_COMMAND
Definition: winuser.h:1730
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define SendMessage
Definition: winuser.h:5833
HWND WINAPI GetParent(_In_ HWND)
#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 */
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);
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}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL MyDrawEdge(HDC hDC, LPRECT rc, UINT edge, UINT flags, COLOR_SCHEME *scheme)
Definition: draw.c:386
VOID MyDrawScrollbar(HDC hdc, LPRECT rc, HBRUSH hbrScrollbar, COLOR_SCHEME *scheme)
Definition: draw.c:424
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
BOOL MyDrawCaptionTemp(HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, HICON hIcon, LPCWSTR str, UINT uFlags, COLOR_SCHEME *scheme)
Definition: draw.c:457
BOOL MyDrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState, COLOR_SCHEME *scheme)
Definition: draw.c:371
#define MY_BF_ACTIVEBORDER
Definition: draw.h:16
#define MY_BF_INACTIVEBORDER
Definition: draw.h:17
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
static HDC
Definition: imagelist.c:92
HDC hdcPreview
Definition: preview.c:15
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define SRCCOPY
Definition: wingdi.h:333
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
#define COLOR_BTNTEXT
Definition: winuser.h:927
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:928
#define EDGE_SUNKEN
Definition: winuser.h:451
#define COLOR_WINDOW
Definition: winuser.h:912
#define DT_CENTER
Definition: winuser.h:527
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define COLOR_WINDOWTEXT
Definition: winuser.h:915
#define DT_SINGLELINE
Definition: winuser.h:540
#define DC_ACTIVE
Definition: winuser.h:427
#define DFC_BUTTON
Definition: winuser.h:476
#define BF_ADJUST
Definition: winuser.h:470
#define BF_MIDDLE
Definition: winuser.h:468
#define DrawText
Definition: winuser.h:5761
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DC_TEXT
Definition: winuser.h:430
#define DT_VCENTER
Definition: winuser.h:543
#define DC_ICON
Definition: winuser.h:429
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define BF_RECT
Definition: winuser.h:462
#define COLOR_CAPTIONTEXT
Definition: winuser.h:916
#define EDGE_RAISED
Definition: winuser.h:450

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}
static VOID CalculateItemSize(PPREVIEW_DATA pPreviewData)
Definition: preview.c:143
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585

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
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
527 pPreviewData->hdcPreview = (HDC)lParam;
529 break;
530
531 default:
532 return DefWindowProc(hwnd, uMsg, wParam, lParam);
533 }
534 return FALSE;
535}
PLOGFONTW SchemeGetFont(COLOR_SCHEME *scheme, int id)
int SchemeGetMetric(COLOR_SCHEME *scheme, int id)
#define FONT_MESSAGE
Definition: appearance.h:22
#define FONT_CAPTION
Definition: appearance.h:18
#define FONT_MENU
Definition: appearance.h:20
VOID SchemeSetMetric(COLOR_SCHEME *scheme, int id, int value)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
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
static VOID OnCreate(HWND hwnd, PPREVIEW_DATA pPreviewData)
Definition: preview.c:112
static VOID OnLButtonDown(HWND hwnd, int xPos, int yPos, PPREVIEW_DATA pPreviewData)
Definition: preview.c:338
struct _PREVIEW_DATA PREVIEW_DATA
struct _PREVIEW_DATA * PPREVIEW_DATA
static VOID OnDestroy(PPREVIEW_DATA pPreviewData)
Definition: preview.c:396
#define PVM_GETSIZE
Definition: preview.h:27
#define PVM_SETFONT
Definition: preview.h:28
#define PVM_SETSIZE
Definition: preview.h:26
#define PVM_UPDATETHEME
Definition: preview.h:33
#define PVM_GETFONT
Definition: preview.h:29
#define PVM_SET_HDC_PREVIEW
Definition: preview.h:32
#define PVM_SETCOLOR
Definition: preview.h:30
#define PVM_GETCOLOR
Definition: preview.h:31
#define DefWindowProc
Definition: ros2win.h:31
COLORREF crColor[NUM_COLORS]
Definition: appearance.h:61
NONCLIENTMETRICSW ncMetrics
Definition: appearance.h:59
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LRESULT
Definition: windef.h:209
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define CreateFontIndirect
Definition: wingdi.h:4444
#define WM_PAINT
Definition: winuser.h:1610
#define COLOR_SCROLLBAR
Definition: winuser.h:906
#define WM_CREATE
Definition: winuser.h:1598
#define WM_SIZE
Definition: winuser.h:1601
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
#define COLOR_DESKTOP
Definition: winuser.h:908
#define WM_DESTROY
Definition: winuser.h:1599
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

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}
HINSTANCE hInstance
Definition: charmap.c:19
WORD ATOM
Definition: dimm.idl:113
static const TCHAR szPreviewWndClass[]
Definition: preview.c:11
static LRESULT CALLBACK PreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: preview.c:418
HINSTANCE hInstance
Definition: winuser.h:3196
HCURSOR hCursor
Definition: winuser.h:3198
UINT cbSize
Definition: winuser.h:3191
WNDPROC lpfnWndProc
Definition: winuser.h:3193
LPCSTR lpszClassName
Definition: winuser.h:3201
HBRUSH hbrBackground
Definition: winuser.h:3199
#define IDC_ARROW
Definition: winuser.h:682
#define RegisterClassEx
Definition: winuser.h:5827
#define LoadCursor
Definition: winuser.h:5802

Referenced by DllMain().

◆ UnregisterPreviewControl()

VOID UnregisterPreviewControl ( IN HINSTANCE  hInstance)

Definition at line 555 of file preview.c.

556{
558}
#define UnregisterClass
Definition: winuser.h:5851

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}

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