- Fix KiDispatchException to unmask KI_EXCEPTION_INTERNAL when setting the exception...
[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 COLORREF crColor = g->ThemeAdv.crColor[nColor];
27 HGDIOBJ hgdiTmp;
28
29 if (nColor != -1)
30 {
31 /* Create a DC to draw on */
32 hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
33 hdcColorButton = GetDC(hwndColorButton);
34 hdcCompat = CreateCompatibleDC(hdcColorButton);
35 ReleaseDC(hwndColorButton, hdcColorButton);
36
37 /* Select the button image to it */
38 hgdiTmp = SelectObject(hdcCompat, g->hbmpColor[nButton]);
39
40 /* Create a brush and draw the rectangle */
41 rect.left = 2;
42 rect.top = 2;
43 rect.right = 22;
44 rect.bottom = 13;
45 hbrush = CreateSolidBrush(crColor);
46 FillRect(hdcCompat, &rect, hbrush);
47 DeleteObject(hbrush);
48
49 /* hdcCompat is not needed anymore */
50 SelectObject(hdcCompat,hgdiTmp);
51 DeleteDC(hdcCompat);
52
53 SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[nButton]);
54 EnableWindow(GetDlgItem(hwndDlg, ID), TRUE);
55 }
56 else
57 {
58 SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)NULL);
59 EnableWindow(GetDlgItem(hwndDlg, ID), FALSE);
60 }
61 }
62
63
64 /* Create the basic bitmaps for the color picker buttons */
65 static VOID
66 InitColorButtons(HWND hwndDlg, GLOBALS* g)
67 {
68 INT i;
69 HDC hdcColorButton, hdcCompat;
70 RECT rect;
71 HBRUSH hbrush;
72 HPEN hPen;
73 HWND hwndColorButton;
74 HGDIOBJ hgdiTemp;
75
76 const POINT Points[3] = {{29,6},{33,6},{31,8}};
77
78 hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
79 hdcColorButton = GetDC(hwndColorButton);
80 for (i = 0; i <= 2; i++)
81 {
82 /* Create a DC to draw on */
83 hdcCompat = CreateCompatibleDC(hdcColorButton);
84
85 /* Create the button image */
86 g->hbmpColor[i] = CreateCompatibleBitmap(hdcColorButton, 36, 15);
87
88 /* Select the button image to the DC */
89 hgdiTemp = SelectObject(hdcCompat, g->hbmpColor[i]);
90
91 /* Draw the buttons background color */
92 rect.left = 0;
93 rect.top = 0;
94 rect.right = 36;
95 rect.bottom = 15;
96 hbrush = CreateSolidBrush(g->crCOLOR_BTNFACE);
97 FillRect(hdcCompat, &rect, hbrush);
98 DeleteObject(hbrush);
99
100 /* Draw the rectangle */
101 rect.left = 1;
102 rect.top = 1;
103 rect.right = 23;
104 rect.bottom = 14;
105 hbrush = CreateSolidBrush(g->crCOLOR_BTNTEXT);
106 FillRect(hdcCompat, &rect, hbrush);
107 DeleteObject(hbrush);
108
109 /* Draw left side of line */
110 hPen = CreatePen(PS_SOLID, 1, g->crCOLOR_BTNSHADOW);
111 SelectObject(hdcCompat, hPen);
112 MoveToEx(hdcCompat, 26, 1, NULL);
113 LineTo(hdcCompat, 26, 14);
114 SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
115 DeleteObject(hPen);
116
117 /* Draw right side of line */
118 hPen = CreatePen(PS_SOLID, 1, g->crCOLOR_BTNHIGHLIGHT);
119 SelectObject(hdcCompat,hPen);
120 MoveToEx(hdcCompat, 27, 1, NULL);
121 LineTo(hdcCompat, 27, 14);
122 SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
123 DeleteObject(hPen);
124
125 /* Draw triangle */
126 hPen = CreatePen(PS_SOLID, 1, g->crCOLOR_BTNTEXT);
127 hbrush = CreateSolidBrush(g->crCOLOR_BTNTEXT);
128 SelectObject(hdcCompat, hPen);
129 SelectObject(hdcCompat, hbrush);
130 SetPolyFillMode(hdcCompat, WINDING);
131
132 /* FIXME: HACK, see Points definition */
133 Polygon(hdcCompat, Points, 3);
134
135 /* Cleanup */
136 SelectObject(hdcCompat,hgdiTemp);
137 DeleteDC(hdcCompat);
138 DeleteObject(hPen);
139 DeleteObject(hbrush);
140 }
141
142 ReleaseDC(hwndColorButton, hdcColorButton);
143
144 /* Set the images of the buttons */
145 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[0]);
146 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[1]);
147 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[2]);
148 }
149
150
151 /* This is the callback function to add the installed fonts to the font combo */
152 static int CALLBACK
153 EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD dwFontType, LPARAM lParam)
154 {
155 /* Don't enumerate more than 100 fonts */
156 if (SendMessage((HWND)lParam, CB_GETCOUNT, 0, 0) >= 100)
157 return 0;
158
159 /* Only add the string once */
160 if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (WPARAM)&(lpelfe->elfLogFont.lfFaceName)) != CB_ERR)
161 return 2;
162
163 SendMessage((HWND)lParam, CB_ADDSTRING, 0, (WPARAM)&(lpelfe->elfLogFont.lfFaceName));
164
165 return 1;
166 }
167
168
169 /* Update all the controls with the current values for the selected screen element */
170 static VOID
171 UpdateControls(HWND hwndDlg, GLOBALS *g)
172 {
173 INT iElement;
174 HDC hdcDlg;
175
176 iElement = g->CurrentElement;
177
178 /* First enable / disable the controls */
179 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E), (g_Assignment[iElement].Size != -1));
180 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD), (g_Assignment[iElement].Size != -1));
181 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_T), (g_Assignment[iElement].Size != -1));
182 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_T), (g_Assignment[iElement].Color1 != -1));
183 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_T), (g_Assignment[iElement].Color2 != -1));
184 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_T), (g_Assignment[iElement].Font != -1));
185 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_C), (g_Assignment[iElement].Font != -1));
186 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_T), (g_Assignment[iElement].Font != -1));
187 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E), (g_Assignment[iElement].Font != -1));
188 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_T), (g_Assignment[iElement].FontColor != -1));
189 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD), (g_Assignment[iElement].Font != -1));
190 EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC), (g_Assignment[iElement].Font != -1));
191
192 /* Update the colors of the color buttons */
193 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR1_B, 0, g_Assignment[iElement].Color1);
194 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR2_B, 1, g_Assignment[iElement].Color2);
195 UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_FONTCOLOR_B, 2, g_Assignment[iElement].FontColor);
196
197 if (g_Assignment[iElement].Size != -1)
198 SetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, g->ThemeAdv.Size[g_Assignment[iElement].Size], FALSE);
199 else
200 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, TEXT(""));
201
202 hdcDlg = GetDC(hwndDlg);
203 if (g_Assignment[iElement].Font != -1)
204 {
205 LOGFONT lfFont = g->ThemeAdv.lfFont[g_Assignment[iElement].Font];
206
207 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, lfFont.lfFaceName);
208 SetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, -MulDiv(g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfHeight, 72, GetDeviceCaps(hdcDlg, LOGPIXELSY)),FALSE);
209 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, CB_FINDSTRINGEXACT, -1, (WPARAM)lfFont.lfFaceName);
210 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK, g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfWeight == FW_BOLD?1:0, 0);
211 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK, g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfItalic, 0);
212 }
213 else
214 {
215 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, NULL);
216 SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, NULL);
217 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK, 0, 0);
218 SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK, 0, 0);
219 }
220
221 ReleaseDC(hwndDlg, hdcDlg);
222 }
223
224
225 static VOID
226 SaveCurrentValues(HWND hwndDlg, GLOBALS *g)
227 {
228 BOOL bTranslated;
229 HDC hdcDlg = GetDC(hwndDlg);
230
231 if (g_Assignment[g->CurrentElement].Size != -1)
232 {
233 g->ThemeAdv.Size[g_Assignment[g->CurrentElement].Size] = GetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, &bTranslated, FALSE);
234 }
235
236 if (g_Assignment[g->CurrentElement].Font != -1)
237 {
238 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight = -MulDiv(GetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, &bTranslated, FALSE), GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
239 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight = (SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0) == 1)?FW_BOLD:FW_NORMAL;
240 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
241 GetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName, LF_FACESIZE * sizeof(TCHAR));
242 }
243
244 ReleaseDC(hwndDlg, hdcDlg);
245 }
246
247
248 /* Select a color using a color picker */
249 static BOOL
250 GetColor(HWND hwndDlg, GLOBALS* g, INT nButton)
251 {
252 CHOOSECOLOR cc;
253 COLORREF crCustom[16] = { 0 };
254 COLORREF crColor;
255 INT ID = 0;
256 INT ColorIndex = 0;
257
258 /* Get the color index from the element index and button number */
259 switch (nButton)
260 {
261 case 0:
262 ColorIndex = g_Assignment[g->CurrentElement].Color1;
263 ID = IDC_ADVAPPEARANCE_COLOR1_B;
264 break;
265
266 case 1:
267 ColorIndex = g_Assignment[g->CurrentElement].Color2;
268 ID = IDC_ADVAPPEARANCE_COLOR2_B;
269 break;
270
271 case 2:
272 ColorIndex = g_Assignment[g->CurrentElement].FontColor;
273 ID = IDC_ADVAPPEARANCE_FONTCOLOR_B;
274 break;
275 }
276
277 crColor = g->ThemeAdv.crColor[ColorIndex];
278
279 /* Prepare cc structure */
280 cc.lStructSize = sizeof(CHOOSECOLOR);
281 cc.hwndOwner = hwndDlg;
282 cc.hInstance = NULL;
283 cc.rgbResult = crColor;
284 cc.lpCustColors = crCustom;
285 cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
286 cc.lCustData = 0;
287 cc.lpfnHook = NULL;
288 cc.lpTemplateName = NULL;
289
290 /* Create the colorpicker */
291 if (ChooseColor(&cc))
292 {
293 g->ThemeAdv.crColor[ColorIndex] = cc.rgbResult;
294 if (crColor != cc.rgbResult)
295 {
296 UpdateButtonColor(hwndDlg, g, ID, nButton, ColorIndex);
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
472 INT_PTR CALLBACK
473 AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
474 {
475 INT iListIndex;
476 GLOBALS* g;
477
478 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
479
480 switch (uMsg)
481 {
482 case WM_INITDIALOG:
483 g = (GLOBALS*)lParam;
484 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
485 AdvAppearanceDlg_Init(hwndDlg, g);
486 break;
487
488 case WM_DESTROY:
489 AdvAppearanceDlg_CleanUp(hwndDlg, g);
490 break;
491
492 case WM_COMMAND:
493 switch(LOWORD(wParam))
494 {
495 case IDOK:
496 SaveCurrentValues(hwndDlg, g);
497 EndDialog(hwndDlg, 0);
498 break;
499
500 case IDCANCEL:
501 g->ThemeAdv = g->Theme;
502 EndDialog(hwndDlg, 0);
503 break;
504
505 case IDC_APPEARANCE_PREVIEW:
506 SaveCurrentValues(hwndDlg, g);
507 SelectComboByElement(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, lParam);
508 g->CurrentElement = (INT)lParam;
509 UpdateControls(hwndDlg, g);
510 break;
511
512 case IDC_ADVAPPEARANCE_ELEMENT:
513 if (HIWORD(wParam) == CBN_SELCHANGE)
514 {
515 SaveCurrentValues(hwndDlg, g);
516 iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
517 g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
518 UpdateControls(hwndDlg, g);
519 }
520 break;
521
522 case IDC_ADVAPPEARANCE_SIZE_E:
523 if (g && HIWORD(wParam) == EN_CHANGE)
524 {
525 int i = (int)LOWORD(SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD, UDM_GETPOS,0,0L));
526
527 switch (g->CurrentElement)
528 {
529 case IDX_INACTIVE_CAPTION:
530 case IDX_ACTIVE_CAPTION:
531 case IDX_CAPTION_BUTTON:
532 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYCAPTION, 0, i);
533 break;
534
535 case IDX_MENU:
536 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYMENU, 0, i);
537 break;
538
539 case IDX_SCROLLBAR:
540 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCXSCROLLBAR, 0, i);
541 break;
542
543 case IDX_INACTIVE_BORDER:
544 case IDX_ACTIVE_BORDER:
545 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYSIZEFRAME, 0, i);
546 break;
547 }
548 }
549 break;
550
551 case IDC_ADVAPPEARANCE_FONT_C:
552 if (g && HIWORD(wParam) == CBN_SELCHANGE)
553 {
554 switch (g->CurrentElement)
555 {
556 case IDX_INACTIVE_CAPTION:
557 case IDX_ACTIVE_CAPTION:
558 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
559 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
560 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
561 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
562 break;
563
564 case IDX_MENU:
565 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
566 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
567 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
568 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
569 break;
570
571 case IDX_DIALOG:
572 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
573 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
574 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
575 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
576 break;
577 }
578 }
579 break;
580
581 case IDC_ADVAPPEARANCE_FONTSIZE_E:
582 if (g && HIWORD(wParam) == CBN_SELCHANGE)
583 {
584 HDC hdcDlg = GetDC(hwndDlg);
585 INT i;
586
587 switch (g->CurrentElement)
588 {
589 case IDX_INACTIVE_CAPTION:
590 case IDX_ACTIVE_CAPTION:
591 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
592 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
593 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
594 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
595 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
596 break;
597
598 case IDX_MENU:
599 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
600 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
601 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
602 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
603 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
604 break;
605
606 case IDX_DIALOG:
607 i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
608 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
609 -MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
610 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
611 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
612 break;
613 }
614
615 ReleaseDC(hwndDlg, hdcDlg);
616 }
617 break;
618
619 case IDC_ADVAPPEARANCE_COLOR1_B:
620 GetColor(hwndDlg, g, 0);
621 break;
622
623 case IDC_ADVAPPEARANCE_COLOR2_B:
624 GetColor(hwndDlg, g, 1);
625 break;
626
627 case IDC_ADVAPPEARANCE_FONTCOLOR_B:
628 GetColor(hwndDlg, g, 2);
629 break;
630
631 default:
632 return FALSE;
633 }
634 break;
635
636 default:
637 return FALSE;
638 }
639
640 return TRUE;
641 }