Use wsprintf() to convert an integer to a string instead of abusing a hidden edit...
[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
454 INT_PTR CALLBACK
455 AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
456 {
457 INT iListIndex;
458 GLOBALS* g;
459
460 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
461
462 switch (uMsg)
463 {
464 case WM_INITDIALOG:
465 g = (GLOBALS*)lParam;
466 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
467 AdvAppearanceDlg_Init(hwndDlg, g);
468 break;
469
470 case WM_DESTROY:
471 AdvAppearanceDlg_CleanUp(hwndDlg, g);
472 break;
473
474 case WM_COMMAND:
475 switch(LOWORD(wParam))
476 {
477 case IDOK:
478 SaveCurrentValues(hwndDlg, g);
479 EndDialog(hwndDlg, 0);
480 break;
481
482 case IDCANCEL:
483 g->ThemeAdv = g->Theme;
484 EndDialog(hwndDlg, 0);
485 break;
486
487 case IDC_APPEARANCE_PREVIEW:
488 SaveCurrentValues(hwndDlg, g);
489 SelectComboByElement(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, lParam);
490 g->CurrentElement = (INT)lParam;
491 UpdateControls(hwndDlg, g);
492 break;
493
494 case IDC_ADVAPPEARANCE_ELEMENT:
495 if (HIWORD(wParam) == CBN_SELCHANGE)
496 {
497 SaveCurrentValues(hwndDlg, g);
498 iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
499 g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
500 UpdateControls(hwndDlg, g);
501 }
502 break;
503
504 case IDC_ADVAPPEARANCE_SIZE_E:
505 if (g && HIWORD(wParam) == EN_CHANGE)
506 {
507 int i = (int)LOWORD(SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD, UDM_GETPOS,0,0L));
508
509 switch (g->CurrentElement)
510 {
511 case IDX_INACTIVE_CAPTION:
512 case IDX_ACTIVE_CAPTION:
513 case IDX_CAPTION_BUTTON:
514 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYCAPTION, 0, i);
515 break;
516
517 case IDX_MENU:
518 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYMENU, 0, i);
519 break;
520
521 case IDX_SCROLLBAR:
522 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCXSCROLLBAR, 0, i);
523 break;
524
525 case IDX_INACTIVE_BORDER:
526 case IDX_ACTIVE_BORDER:
527 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYSIZEFRAME, 0, i);
528 break;
529 }
530 }
531 break;
532
533 case IDC_ADVAPPEARANCE_FONT_C:
534 if (g && HIWORD(wParam) == CBN_SELCHANGE)
535 {
536 switch (g->CurrentElement)
537 {
538 case IDX_INACTIVE_CAPTION:
539 case IDX_ACTIVE_CAPTION:
540 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
541 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
542 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCAPTIONFONT, 0,
543 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
544 break;
545
546 case IDX_MENU:
547 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
548 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
549 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETMENUFONT, 0,
550 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
551 break;
552
553 case IDX_DIALOG:
554 GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
555 g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
556 SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETDIALOGFONT, 0,
557 (LPARAM)&g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font]);
558 break;
559
560 }
561 }
562 break;
563
564 case IDC_ADVAPPEARANCE_COLOR1_B:
565 GetColor(hwndDlg, g, 0);
566 break;
567
568 case IDC_ADVAPPEARANCE_COLOR2_B:
569 GetColor(hwndDlg, g, 1);
570 break;
571
572 case IDC_ADVAPPEARANCE_FONTCOLOR_B:
573 GetColor(hwndDlg, g, 2);
574 break;
575
576 default:
577 return FALSE;
578 }
579 break;
580
581 default:
582 return FALSE;
583 }
584
585 return TRUE;
586 }