[KSPROXY]
[reactos.git] / reactos / dll / cpl / desk / advappdlg.c
1 /* $Id: advappdlg.c 24836 2007-02-12 03:12:56Z tkreuzer $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS Display Control Panel
5 * FILE: dll/cpl/desk/advappdlg.c
6 * PURPOSE: Advanced appearance dialog
7 *
8 * PROGRAMMER: Timo Kreuzer (timo[dot]kreuzer[at]web[dot]de)
9 *
10 */
11
12 #include "desk.h"
13 #include "appearance.h"
14 #include "preview.h"
15
16
17
18 /* Draw the current color on the color picker buttons */
19 static VOID
20 UpdateButtonColor(HWND hwndDlg, GLOBALS* g, INT ID, INT nButton, INT nColor)
21 {
22 HDC hdcColorButton, hdcCompat;
23 RECT rect;
24 HBRUSH hbrush;
25 HWND hwndColorButton;
26 HGDIOBJ hgdiTmp;
27
28 if (nColor != -1)
29 {
30 /* Create a DC to draw on */
31 hwndColorButton = GetDlgItem(hwndDlg, ID);
32 hdcColorButton = GetDC(hwndColorButton);
33 hdcCompat = CreateCompatibleDC(hdcColorButton);
34 ReleaseDC(hwndColorButton, hdcColorButton);
35
36 /* Select the button image to it */
37 hgdiTmp = SelectObject(hdcCompat, g->hbmpColor[nButton]);
38
39 /* Create a brush and draw the rectangle */
40 rect.left = 2;
41 rect.top = 2;
42 rect.right = 22;
43 rect.bottom = 13;
44 hbrush = CreateSolidBrush(g->ThemeAdv.crColor[nColor]);
45 FillRect(hdcCompat, &rect, hbrush);
46 DeleteObject(hbrush);
47
48 /* hdcCompat is not needed anymore */
49 SelectObject(hdcCompat,hgdiTmp);
50 DeleteDC(hdcCompat);
51
52 SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[nButton]);
53 EnableWindow(GetDlgItem(hwndDlg, ID), TRUE);
54 }
55 else
56 {
57 SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)NULL);
58 EnableWindow(GetDlgItem(hwndDlg, ID), FALSE);
59 }
60 }
61
62
63 /* Create the basic bitmaps for the color picker buttons */
64 static VOID
65 InitColorButtons(HWND hwndDlg, GLOBALS* g)
66 {
67 INT i;
68 HDC hdcColorButton, hdcCompat;
69 RECT rect;
70 HBRUSH hbrush;
71 HPEN hPen;
72 HWND hwndColorButton;
73 HGDIOBJ hgdiTemp;
74
75 const POINT Points[3] = {{29,6},{33,6},{31,8}};
76
77 hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
78 hdcColorButton = GetDC(hwndColorButton);
79 for (i = 0; i <= 2; i++)
80 {
81 /* Create a DC to draw on */
82 hdcCompat = CreateCompatibleDC(hdcColorButton);
83
84 /* Create the button image */
85 g->hbmpColor[i] = CreateCompatibleBitmap(hdcColorButton, 36, 15);
86
87 /* Select the button image to the DC */
88 hgdiTemp = SelectObject(hdcCompat, g->hbmpColor[i]);
89
90 /* Draw the buttons background color */
91 rect.left = 0;
92 rect.top = 0;
93 rect.right = 36;
94 rect.bottom = 15;
95 hbrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
96 FillRect(hdcCompat, &rect, hbrush);
97 DeleteObject(hbrush);
98
99 /* Draw the rectangle */
100 rect.left = 1;
101 rect.top = 1;
102 rect.right = 23;
103 rect.bottom = 14;
104 hbrush = CreateSolidBrush(GetSysColor(COLOR_BTNTEXT));
105 FillRect(hdcCompat, &rect, hbrush);
106 DeleteObject(hbrush);
107
108 /* Draw left side of line */
109 hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
110 SelectObject(hdcCompat, hPen);
111 MoveToEx(hdcCompat, 26, 1, NULL);
112 LineTo(hdcCompat, 26, 14);
113 SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
114 DeleteObject(hPen);
115
116 /* Draw right side of line */
117 hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
118 SelectObject(hdcCompat,hPen);
119 MoveToEx(hdcCompat, 27, 1, NULL);
120 LineTo(hdcCompat, 27, 14);
121 SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
122 DeleteObject(hPen);
123
124 /* Draw triangle */
125 hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNTEXT));
126 hbrush = CreateSolidBrush(GetSysColor(COLOR_BTNTEXT));
127 SelectObject(hdcCompat, hPen);
128 SelectObject(hdcCompat, hbrush);
129 SetPolyFillMode(hdcCompat, WINDING);
130
131 /* FIXME: HACK, see Points definition */
132 Polygon(hdcCompat, Points, 3);
133
134 /* Cleanup */
135 SelectObject(hdcCompat,hgdiTemp);
136 DeleteDC(hdcCompat);
137 DeleteObject(hPen);
138 DeleteObject(hbrush);
139 }
140
141 ReleaseDC(hwndColorButton, hdcColorButton);
142
143 /* Set the images of the buttons */
144 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[0]);
145 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[1]);
146 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[2]);
147 }
148
149
150 /* This is the callback function to add the installed fonts to the font combo */
151 static int CALLBACK
152 EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD dwFontType, LPARAM lParam)
153 {
154 /* Don't enumerate more than 100 fonts */
155 if (SendMessage((HWND)lParam, CB_GETCOUNT, 0, 0) >= 100)
156 return 0;
157
158 /* Only add the string once */
159 if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (WPARAM)&(lpelfe->elfLogFont.lfFaceName)) != CB_ERR)
160 return 2;
161
162 SendMessage((HWND)lParam, CB_ADDSTRING, 0, (WPARAM)&(lpelfe->elfLogFont.lfFaceName));
163
164 return 1;
165 }
166
167
168 /* Update all the controls with the current values for the selected screen element */
169 static VOID
170 UpdateControls(HWND hwndDlg, GLOBALS *g)
171 {
172 INT iElement;
173 HDC hdcDlg;
174
175 iElement = g->CurrentElement;
176
177 /* First enable / disable the controls */
178 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E), (g_Assignment[iElement].Size != -1));
179 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD), (g_Assignment[iElement].Size != -1));
180 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_T), (g_Assignment[iElement].Size != -1));
181 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_T), (g_Assignment[iElement].Color1 != -1));
182 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_T), (g_Assignment[iElement].Color2 != -1));
183 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_T), (g_Assignment[iElement].Font != -1));
184 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_C), (g_Assignment[iElement].Font != -1));
185 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_T), (g_Assignment[iElement].Font != -1));
186 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E), (g_Assignment[iElement].Font != -1));
187 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_T), (g_Assignment[iElement].FontColor != -1));
188 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD), (g_Assignment[iElement].Font != -1));
189 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC), (g_Assignment[iElement].Font != -1));
190
191 /* Update the colors of the color buttons */
192 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR1_B, 0, g_Assignment[iElement].Color1);
193 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR2_B, 1, g_Assignment[iElement].Color2);
194 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_FONTCOLOR_B, 2, g_Assignment[iElement].FontColor);
195
196 if (g_Assignment[iElement].Size != -1)
197 SetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, g->ThemeAdv.Size[g_Assignment[iElement].Size], FALSE);
198 else
199 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, TEXT(""));
200
201 hdcDlg = GetDC(hwndDlg);
202 if (g_Assignment[iElement].Font != -1)
203 {
204 LOGFONT lfFont = g->ThemeAdv.lfFont[g_Assignment[iElement].Font];
205
206 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, lfFont.lfFaceName);
207 SetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, -MulDiv(g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfHeight, 72, GetDeviceCaps(hdcDlg, LOGPIXELSY)),FALSE);
208 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, CB_FINDSTRINGEXACT, -1, (WPARAM)lfFont.lfFaceName);
209 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK, g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfWeight == FW_BOLD?1:0, 0);
210 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK, g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfItalic, 0);
211 }
212 else
213 {
214 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, NULL);
215 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, NULL);
216 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK, 0, 0);
217 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK, 0, 0);
218 }
219
220 ReleaseDC(hwndDlg, hdcDlg);
221 }
222
223
224 static VOID
225 SaveCurrentValues(HWND hwndDlg, GLOBALS *g)
226 {
227 BOOL bTranslated;
228 HDC hdcDlg = GetDC(hwndDlg);
229
230 if (g_Assignment[g->CurrentElement].Size != -1)
231 {
232 g->ThemeAdv.Size[g_Assignment[g->CurrentElement].Size] = GetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, &bTranslated, FALSE);
233 }
234
235 if (g_Assignment[g->CurrentElement].Font != -1)
236 {
237 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight = -MulDiv(GetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, &bTranslated, FALSE), GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
238 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight = (SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0) == 1)?FW_BOLD:FW_NORMAL;
239 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
240 GetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName, LF_FACESIZE * sizeof(TCHAR));
241 }
242
243 ReleaseDC(hwndDlg, hdcDlg);
244 }
245
246
247 /* Select a color using a color picker */
248 static BOOL
249 GetColor(HWND hwndDlg, GLOBALS* g, INT nButton)
250 {
251 CHOOSECOLOR cc;
252 COLORREF crCustom[16] = { 0 };
253 COLORREF crColor;
254 INT ID = 0;
255 INT ColorIndex = 0;
256
257 /* Get the color index from the element index and button number */
258 switch (nButton)
259 {
260 case 0:
261 ColorIndex = g_Assignment[g->CurrentElement].Color1;
262 ID = IDC_ADVAPPEARANCE_COLOR1_B;
263 break;
264
265 case 1:
266 ColorIndex = g_Assignment[g->CurrentElement].Color2;
267 ID = IDC_ADVAPPEARANCE_COLOR2_B;
268 break;
269
270 case 2:
271 ColorIndex = g_Assignment[g->CurrentElement].FontColor;
272 ID = IDC_ADVAPPEARANCE_FONTCOLOR_B;
273 break;
274 }
275
276 crColor = g->ThemeAdv.crColor[ColorIndex];
277
278 /* Prepare cc structure */
279 cc.lStructSize = sizeof(CHOOSECOLOR);
280 cc.hwndOwner = hwndDlg;
281 cc.hInstance = NULL;
282 cc.rgbResult = crColor;
283 cc.lpCustColors = crCustom;
284 cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
285 cc.lCustData = 0;
286 cc.lpfnHook = NULL;
287 cc.lpTemplateName = NULL;
288
289 /* Create the colorpicker */
290 if (ChooseColor(&cc))
291 {
292 g->ThemeAdv.crColor[ColorIndex] = cc.rgbResult;
293 if (crColor != cc.rgbResult)
294 {
295 UpdateButtonColor(hwndDlg, g, ID, nButton, ColorIndex);
296 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCOLOR, ColorIndex, cc.rgbResult);
297 return TRUE;
298 }
299 }
300
301 return FALSE;
302 }
303
304
305 /* Initialize the advanced appearance dialog */
306 static VOID
307 AdvAppearanceDlg_Init(HWND hwndDlg, GLOBALS *g)
308 {
309 INT i, iElement, iListIndex, iDeskIndex = 0;
310 TCHAR tstrText[80];
311 LOGFONT lfFont;
312 LOGFONT lfButtonFont;
313 HFONT hMyFont;
314 HDC hScreenDC;
315 TCHAR Size[4];
316
317 /* Copy the current theme values */
318 g->ThemeAdv = g->Theme;
319
320 /* Add the elements to the combo */
321 for (iElement = 0; iElement < NUM_ELEMENTS; iElement++)
322 {
323 LoadString(hApplet, IDS_ELEMENT_1 + iElement, (LPTSTR)&tstrText, 79);
324 iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_ADDSTRING, 0, (LPARAM)&tstrText);
325 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETITEMDATA, (WPARAM)iListIndex, (LPARAM)iElement);
326 }
327
328 /* Get the list index of the desktop element */
329 for (iListIndex = 0; iListIndex < NUM_ELEMENTS; iListIndex++)
330 {
331 iElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
332 if (iElement == 0)
333 {
334 iDeskIndex = iListIndex;
335 break;
336 }
337 }
338
339 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETCURSEL, iDeskIndex, 0);
340
341 /* Set colors for the color buttons */
342 g->crCOLOR_BTNFACE = g->Theme.crColor[COLOR_BTNFACE];
343 g->crCOLOR_BTNTEXT = g->Theme.crColor[COLOR_BTNTEXT];
344 g->crCOLOR_BTNSHADOW = g->Theme.crColor[COLOR_BTNSHADOW];
345 g->crCOLOR_BTNHIGHLIGHT = g->Theme.crColor[COLOR_BTNHIGHLIGHT];
346
347 /* Create font for bold button */
348 lfButtonFont = g->Theme.lfFont[FONT_DIALOG];
349 lfButtonFont.lfWeight = FW_BOLD;
350 lfButtonFont.lfItalic = FALSE;
351 hMyFont = CreateFontIndirect(&lfButtonFont);
352 if (hMyFont)
353 {
354 if (g->hBoldFont)
355 DeleteObject(g->hBoldFont);
356
357 g->hBoldFont = hMyFont;
358 }
359
360 /* Create font for italic button */
361 lfButtonFont.lfWeight = FW_REGULAR;
362 lfButtonFont.lfItalic = TRUE;
363 hMyFont = CreateFontIndirect(&lfButtonFont);
364 if (hMyFont)
365 {
366 if (g->hItalicFont)
367 DeleteObject(g->hItalicFont);
368
369 g->hItalicFont = hMyFont;
370 }
371
372 /* Set the fonts for the font style buttons */
373 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, WM_SETFONT, (WPARAM)g->hBoldFont, (LPARAM)TRUE);
374 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, WM_SETFONT, (WPARAM)g->hItalicFont, (LPARAM)TRUE);
375
376 /* Draw Bitmaps for the colorbuttons */
377 InitColorButtons(hwndDlg, g);
378
379 /* Make the UpDown control count correctly */
380 SendMessage (GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD), UDM_SETRANGE, 0L, MAKELONG (200, 1));
381
382 /* Fill font selection combo */
383 lfFont.lfCharSet = DEFAULT_CHARSET;
384 lfFont.lfFaceName[0] = (TCHAR)0;
385 lfFont.lfPitchAndFamily = 0;
386 hScreenDC = GetDC(0);
387 EnumFontFamiliesEx(hScreenDC, &lfFont, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_C), 0);
388 ReleaseDC(0, hScreenDC);
389
390 /* Fill font size combo */
391 for (i = 6; i <= 24; i++)
392 {
393 wsprintf(Size, TEXT("%d"), i);
394 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, CB_ADDSTRING, 0, (LPARAM)&Size);
395 }
396
397 /* Update the controls */
398 iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
399 g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
400 UpdateControls(hwndDlg, g);
401 }
402
403
404 static VOID
405 AdvAppearanceDlg_CleanUp(HWND hwndDlg, GLOBALS* g)
406 {
407 DeleteObject(g->hBoldFont);
408 DeleteObject(g->hItalicFont);
409 }
410
411
412 static VOID
413 SelectComboByElement(HWND hwnd, INT id, LPARAM lParam)
414 {
415 INT nCount;
416 INT i;
417
418 nCount = SendDlgItemMessage(hwnd, id, CB_GETCOUNT, 0, 0);
419 if (nCount == CB_ERR)
420 return;
421
422 for (i = 0; i < nCount; i++)
423 {
424 if (SendDlgItemMessage(hwnd, id, CB_GETITEMDATA, (WPARAM)i, 0) == lParam)
425 {
426 SendDlgItemMessage(hwnd, id, CB_SETCURSEL, (WPARAM)i, 0);
427 break;
428 }
429 }
430 }
431
432
433 static VOID
434 GetSelectedComboText(HWND hwnd, INT id, LPWSTR lpStr)
435 {
436 INT nCount;
437
438 nCount = SendDlgItemMessage(hwnd, id, CB_GETCURSEL, 0, 0);
439 if (nCount == CB_ERR)
440 {
441 *lpStr = 0;
442 return;
443 }
444
445 nCount = SendDlgItemMessage(hwnd, id, CB_GETLBTEXT, (WPARAM)nCount, (LPARAM)lpStr);
446 if (nCount == CB_ERR)
447 {
448 *lpStr = 0;
449 }
450 }
451
452
453 static INT
454 GetSelectedComboInt(HWND hwnd, INT id)
455 {
456 TCHAR szBuffer[80];
457 INT nCount;
458
459 nCount = SendDlgItemMessage(hwnd, id, CB_GETCURSEL, 0, 0);
460 if (nCount == CB_ERR)
461 return 0;
462
463 nCount = SendDlgItemMessage(hwnd, id, CB_GETLBTEXT, (WPARAM)nCount, (LPARAM)szBuffer);
464 if (nCount == CB_ERR)
465 return 0;
466
467 return _ttoi(szBuffer);
468 }
469
470
471 static INT
472 GetEditedComboInt(HWND hwnd, INT id)
473 {
474 INT nCount;
475 BOOL bTranslated;
476
477 nCount = GetDlgItemInt(hwnd, id, &bTranslated, FALSE);
478 if (bTranslated == FALSE)
479 return 12;
480
481 return nCount;
482 }
483
484
485
486 INT_PTR CALLBACK
487 AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
488 {
489 INT iListIndex;
490 GLOBALS* g;
491
492 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
493
494 switch (uMsg)
495 {
496 case WM_INITDIALOG:
497 g = (GLOBALS*)lParam;
498 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
499 AdvAppearanceDlg_Init(hwndDlg, g);
500 break;
501
502 case WM_DESTROY:
503 AdvAppearanceDlg_CleanUp(hwndDlg, g);
504 break;
505
506 case WM_COMMAND:
507 switch(LOWORD(wParam))
508 {
509 case IDOK:
510 SaveCurrentValues(hwndDlg, g);
511 EndDialog(hwndDlg, 0);
512 break;
513
514 case IDCANCEL:
515 g->ThemeAdv = g->Theme;
516 EndDialog(hwndDlg, 0);
517 break;
518
519 case IDC_APPEARANCE_PREVIEW:
520 SaveCurrentValues(hwndDlg, g);
521 SelectComboByElement(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, lParam);
522 g->CurrentElement = (INT)lParam;
523 UpdateControls(hwndDlg, g);
524 break;
525
526 case IDC_ADVAPPEARANCE_ELEMENT:
527 if (HIWORD(wParam) == CBN_SELCHANGE)
528 {
529 SaveCurrentValues(hwndDlg, g);
530 iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
531 g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
532 UpdateControls(hwndDlg, g);
533 }
534 break;
535
536 case IDC_ADVAPPEARANCE_SIZE_E:
537 if (g && HIWORD(wParam) == EN_CHANGE)
538 {
539 INT i = (INT)LOWORD(SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD, UDM_GETPOS,0,0L));
540
541 switch (g->CurrentElement)
542 {
543 case IDX_INACTIVE_CAPTION:
544 case IDX_ACTIVE_CAPTION:
545 case IDX_CAPTION_BUTTON:
546 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYCAPTION, 0, i);
547 break;
548
549 case IDX_MENU:
550 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYMENU, 0, i);
551 break;
552
553 case IDX_SCROLLBAR:
554 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCXSCROLLBAR, 0, i);
555 break;
556
557 case IDX_INACTIVE_BORDER:
558 case IDX_ACTIVE_BORDER:
559 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYSIZEFRAME, 0, i);
560 break;
561 }
562 }
563 break;
564
565 case IDC_ADVAPPEARANCE_FONT_C:
566 if (g && HIWORD(wParam) == CBN_SELCHANGE)
567 {
568 switch (g->CurrentElement)
569 {
570 case IDX_INACTIVE_CAPTION:
571 case IDX_ACTIVE_CAPTION:
572 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
573 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
574 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
575 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
576 break;
577
578 case IDX_MENU:
579 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
580 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
581 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
582 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
583 break;
584
585 case IDX_DIALOG:
586 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
587 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
588 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
589 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
590 break;
591 }
592 }
593 break;
594
595 case IDC_ADVAPPEARANCE_FONTSIZE_E:
596 if (g && HIWORD(wParam) == CBN_SELCHANGE)
597 {
598 HDC hdcDlg = GetDC(hwndDlg);
599 INT i;
600
601 switch (g->CurrentElement)
602 {
603 case IDX_INACTIVE_CAPTION:
604 case IDX_ACTIVE_CAPTION:
605 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
606 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
607 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
608 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
609 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
610 break;
611
612 case IDX_MENU:
613 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
614 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
615 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
616 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
617 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
618 break;
619
620 case IDX_DIALOG:
621 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
622 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
623 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
624 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
625 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
626 break;
627 }
628
629 ReleaseDC(hwndDlg, hdcDlg);
630 }
631 else if (g && HIWORD(wParam) == CBN_EDITCHANGE)
632 {
633 HDC hdcDlg = GetDC(hwndDlg);
634 INT i;
635
636 switch (g->CurrentElement)
637 {
638 case IDX_INACTIVE_CAPTION:
639 case IDX_ACTIVE_CAPTION:
640 i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
641 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
642 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
643 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
644 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
645 break;
646
647 case IDX_MENU:
648 i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
649 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
650 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
651 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
652 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
653 break;
654
655 case IDX_DIALOG:
656 i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
657 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
658 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
659 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
660 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
661 break;
662 }
663
664 ReleaseDC(hwndDlg, hdcDlg);
665 }
666 break;
667
668 case IDC_ADVAPPEARANCE_FONTBOLD:
669 if (g && HIWORD(wParam) == BN_CLICKED)
670 {
671 INT i;
672
673 switch (g->CurrentElement)
674 {
675 case IDX_INACTIVE_CAPTION:
676 case IDX_ACTIVE_CAPTION:
677 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
678 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
679 (i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
680
681 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
682 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
683 break;
684
685 case IDX_MENU:
686 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
687
688 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
689 (i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
690 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
691 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
692 break;
693
694 case IDX_DIALOG:
695 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
696
697 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
698 (i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
699
700 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
701 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
702 break;
703 }
704 }
705 break;
706
707 case IDC_ADVAPPEARANCE_FONTITALIC:
708 if (g && HIWORD(wParam) == BN_CLICKED)
709 {
710 INT i;
711
712 switch (g->CurrentElement)
713 {
714 case IDX_INACTIVE_CAPTION:
715 case IDX_ACTIVE_CAPTION:
716 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
717
718 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
719 (i == BST_CHECKED) ? TRUE : FALSE;
720
721 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
722 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
723 break;
724
725 case IDX_MENU:
726 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
727
728 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
729 (i == BST_CHECKED) ? TRUE : FALSE;
730
731 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
732 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
733 break;
734
735 case IDX_DIALOG:
736 i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
737
738 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
739 (i == BST_CHECKED) ? TRUE : FALSE;
740
741 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
742 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
743 break;
744 }
745 }
746 break;
747
748 case IDC_ADVAPPEARANCE_COLOR1_B:
749 GetColor(hwndDlg, g, 0);
750 break;
751
752 case IDC_ADVAPPEARANCE_COLOR2_B:
753 GetColor(hwndDlg, g, 1);
754 break;
755
756 case IDC_ADVAPPEARANCE_FONTCOLOR_B:
757 GetColor(hwndDlg, g, 2);
758 break;
759
760 default:
761 return FALSE;
762 }
763 break;
764
765 default:
766 return FALSE;
767 }
768
769 return TRUE;
770 }