2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * FILE: dll/cpl/desk/advappdlg.c
5 * PURPOSE: Advanced appearance dialog
7 * PROGRAMMER: Timo Kreuzer (timo[dot]kreuzer[at]web[dot]de)
13 /******************************************************************************/
25 /* This const assigns the color and metric numbers to the elements from the elements list */
27 /* Size 1 (width) Size 2 (height) Color 1 Color 2 Font Fontcolor */
28 const ASSIGNMENT g_Assignment
[NUM_ELEMENTS
] =
30 {-1, -1, COLOR_DESKTOP
, -1, -1, -1}, /* Desktop */
31 {SIZE_CAPTION_HEIGHT
, -1, COLOR_INACTIVECAPTION
, COLOR_GRADIENTINACTIVECAPTION
, FONT_CAPTION
, COLOR_INACTIVECAPTIONTEXT
},/* inactive window caption */
32 {SIZE_BORDER_WIDTH
, -1, COLOR_INACTIVEBORDER
, -1, -1, -1}, /* inactive window border */
33 {SIZE_CAPTION_HEIGHT
, -1, COLOR_ACTIVECAPTION
, COLOR_GRADIENTACTIVECAPTION
, FONT_CAPTION
, COLOR_CAPTIONTEXT
}, /* active window caption */
34 {SIZE_BORDER_WIDTH
, -1, COLOR_ACTIVEBORDER
, -1, -1, -1}, /* active window border */
35 {SIZE_MENU_HEIGHT
, SIZE_MENU_WIDTH
, COLOR_MENU
, COLOR_MENUHILIGHT
, FONT_MENU
, COLOR_MENUTEXT
}, /* menu */
36 {SIZE_MENU_HEIGHT
, SIZE_MENU_WIDTH
, COLOR_HIGHLIGHT
, -1, -1, COLOR_HIGHLIGHTTEXT
},/* marked element */
37 {-1, -1, COLOR_WINDOW
, -1 /*COLOR_WINDOWFRAME*/, -1, COLOR_WINDOWTEXT
}, /* window */
38 {SIZE_SCROLL_WIDTH
, SIZE_SCROLL_HEIGHT
, COLOR_SCROLLBAR
, -1, -1, -1}, /* scroll bar */
39 {-1, -1, COLOR_3DFACE
, -1, -1, COLOR_BTNTEXT
}, /* 3d objects */
40 {SIZE_SM_CAPTION_HEIGHT
, -1, -1, -1, FONT_SMCAPTION
, -1}, /* palette (small) window caption */
41 {SIZE_CAPTION_HEIGHT
, -1, -1, -1, -1, -1}, /* caption bar buttons */
42 {-1, -1, -1, -1, FONT_MESSAGE
, COLOR_WINDOWTEXT
}, /* dialog */
43 {-1, -1, COLOR_APPWORKSPACE
, -1, -1, -1}, /* application background */
44 {SIZE_ICON_SPACE_X
, -1, -1, -1, -1, -1}, /* icon distance horiz. */
45 {SIZE_ICON_SPACE_Y
, -1, -1, -1, -1, -1}, /* icon distance vert. */
46 {-1, -1, COLOR_INFOBK
, -1, FONT_STATUS
, COLOR_INFOTEXT
}, /* quickinfo */
47 {SIZE_ICON
, -1, -1, -1, FONT_ICON
, -1}, /* icon */
48 // {-1, -1, -1, -1, -1, COLOR_GRAYTEXT}, /* inactive menu item -- FIXME: Access? */
51 /******************************************************************************/
53 /* Draw the current color on the color picker buttons */
55 UpdateButtonColor(HWND hwndDlg
, GLOBALS
* g
, INT ID
, INT nButton
, INT nColor
)
57 HDC hdcColorButton
, hdcCompat
;
65 /* Create a DC to draw on */
66 hwndColorButton
= GetDlgItem(hwndDlg
, ID
);
67 hdcColorButton
= GetDC(hwndColorButton
);
68 hdcCompat
= CreateCompatibleDC(hdcColorButton
);
69 ReleaseDC(hwndColorButton
, hdcColorButton
);
71 /* Select the button image to it */
72 hgdiTmp
= SelectObject(hdcCompat
, g
->hbmpColor
[nButton
]);
74 /* Create a brush and draw the rectangle */
79 hbrush
= CreateSolidBrush(g
->SchemeAdv
.crColor
[nColor
]);
80 FillRect(hdcCompat
, &rect
, hbrush
);
83 /* hdcCompat is not needed anymore */
84 SelectObject(hdcCompat
,hgdiTmp
);
87 SendDlgItemMessage(hwndDlg
, ID
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[nButton
]);
88 EnableWindow(GetDlgItem(hwndDlg
, ID
), TRUE
);
92 SendDlgItemMessage(hwndDlg
, ID
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)NULL
);
93 EnableWindow(GetDlgItem(hwndDlg
, ID
), FALSE
);
98 /* Create the basic bitmaps for the color picker buttons */
100 InitColorButtons(HWND hwndDlg
, GLOBALS
* g
)
103 HDC hdcColorButton
, hdcCompat
;
107 HWND hwndColorButton
;
109 COLOR_SCHEME
*scheme
= &g
->SchemeAdv
;
111 const POINT Points
[3] = {{29,6},{33,6},{31,8}};
113 hwndColorButton
= GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_B
);
114 hdcColorButton
= GetDC(hwndColorButton
);
115 for (i
= 0; i
<= 2; i
++)
117 /* Create a DC to draw on */
118 hdcCompat
= CreateCompatibleDC(hdcColorButton
);
120 /* Create the button image */
121 g
->hbmpColor
[i
] = CreateCompatibleBitmap(hdcColorButton
, 36, 15);
123 /* Select the button image to the DC */
124 hgdiTemp
= SelectObject(hdcCompat
, g
->hbmpColor
[i
]);
126 /* Draw the buttons background color */
131 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNFACE
]);
132 FillRect(hdcCompat
, &rect
, hbrush
);
133 DeleteObject(hbrush
);
135 /* Draw the rectangle */
140 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNTEXT
]);
141 FillRect(hdcCompat
, &rect
, hbrush
);
142 DeleteObject(hbrush
);
144 /* Draw left side of line */
145 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNSHADOW
]);
146 SelectObject(hdcCompat
, hPen
);
147 MoveToEx(hdcCompat
, 26, 1, NULL
);
148 LineTo(hdcCompat
, 26, 14);
149 SelectObject(hdcCompat
, GetStockObject(BLACK_PEN
));
152 /* Draw right side of line */
153 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNHIGHLIGHT
]);
154 SelectObject(hdcCompat
,hPen
);
155 MoveToEx(hdcCompat
, 27, 1, NULL
);
156 LineTo(hdcCompat
, 27, 14);
157 SelectObject(hdcCompat
, GetStockObject(BLACK_PEN
));
161 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNTEXT
]);
162 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNTEXT
]);
163 SelectObject(hdcCompat
, hPen
);
164 SelectObject(hdcCompat
, hbrush
);
165 SetPolyFillMode(hdcCompat
, WINDING
);
167 /* FIXME: HACK, see Points definition */
168 Polygon(hdcCompat
, Points
, 3);
171 SelectObject(hdcCompat
,hgdiTemp
);
174 DeleteObject(hbrush
);
177 ReleaseDC(hwndColorButton
, hdcColorButton
);
179 /* Set the images of the buttons */
180 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[0]);
181 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_COLOR2_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[1]);
182 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTCOLOR_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[2]);
186 /* This is the callback function to add the installed fonts to the font combo */
188 EnumFontFamExProc(ENUMLOGFONTEX
*lpelfe
, NEWTEXTMETRICEX
*lpntme
, DWORD dwFontType
, LPARAM lParam
)
190 /* Don't enumerate more than 100 fonts */
191 if (SendMessage((HWND
)lParam
, CB_GETCOUNT
, 0, 0) >= 100)
194 /* Only add the string once */
195 if (SendMessage((HWND
)lParam
, CB_FINDSTRINGEXACT
, -1, (WPARAM
)&(lpelfe
->elfLogFont
.lfFaceName
)) != CB_ERR
)
198 SendMessage((HWND
)lParam
, CB_ADDSTRING
, 0, (WPARAM
)&(lpelfe
->elfLogFont
.lfFaceName
));
204 /* Update all the controls with the current values for the selected screen element */
206 UpdateControls(HWND hwndDlg
, GLOBALS
*g
)
211 iElement
= g
->CurrentElement
;
213 /* First enable / disable the controls */
214 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
), (g_Assignment
[iElement
].Size
!= -1));
215 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
), (g_Assignment
[iElement
].Size
!= -1));
216 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_T
), (g_Assignment
[iElement
].Size
!= -1));
217 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_T
), (g_Assignment
[iElement
].Color1
!= -1));
218 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR2_T
), (g_Assignment
[iElement
].Color2
!= -1));
219 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_T
), (g_Assignment
[iElement
].Font
!= -1));
220 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
), (g_Assignment
[iElement
].Font
!= -1));
221 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_T
), (g_Assignment
[iElement
].Font
!= -1));
222 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
), (g_Assignment
[iElement
].Font
!= -1));
223 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTCOLOR_T
), (g_Assignment
[iElement
].FontColor
!= -1));
224 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
), (g_Assignment
[iElement
].Font
!= -1));
225 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
), (g_Assignment
[iElement
].Font
!= -1));
227 /* Update the colors of the color buttons */
228 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_COLOR1_B
, 0, g_Assignment
[iElement
].Color1
);
229 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_COLOR2_B
, 1, g_Assignment
[iElement
].Color2
);
230 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_FONTCOLOR_B
, 2, g_Assignment
[iElement
].FontColor
);
232 if (g_Assignment
[iElement
].Size
!= -1)
233 SetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, SchemeGetMetric(&g
->SchemeAdv
, g_Assignment
[iElement
].Size
), FALSE
);
235 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, TEXT(""));
237 hdcDlg
= GetDC(hwndDlg
);
238 if (g_Assignment
[iElement
].Font
!= -1)
240 PLOGFONTW plfFont
= SchemeGetFont(&g
->SchemeAdv
, g_Assignment
[iElement
].Font
);
242 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
);
243 SetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, -MulDiv(plfFont
->lfHeight
, 72, GetDeviceCaps(hdcDlg
, LOGPIXELSY
)), FALSE
);
244 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, CB_FINDSTRINGEXACT
, -1, (WPARAM
)plfFont
->lfFaceName
);
245 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_SETCHECK
, plfFont
->lfWeight
== FW_BOLD
?1:0, 0);
246 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_SETCHECK
, plfFont
->lfItalic
, 0);
250 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, NULL
);
251 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, NULL
);
252 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_SETCHECK
, 0, 0);
253 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_SETCHECK
, 0, 0);
256 ReleaseDC(hwndDlg
, hdcDlg
);
261 SaveCurrentValues(HWND hwndDlg
, GLOBALS
*g
)
264 HDC hdcDlg
= GetDC(hwndDlg
);
266 if (g_Assignment
[g
->CurrentElement
].Size
!= -1)
268 SchemeSetMetric(&g
->SchemeAdv
, g_Assignment
[g
->CurrentElement
].Size
, GetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, &bTranslated
, FALSE
));
271 if (g_Assignment
[g
->CurrentElement
].Font
!= -1)
273 PLOGFONTW plfFont
= SchemeGetFont(&g
->SchemeAdv
, g_Assignment
[g
->CurrentElement
].Font
);
274 plfFont
->lfHeight
= -MulDiv(GetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, &bTranslated
, FALSE
), GetDeviceCaps(hdcDlg
, LOGPIXELSY
), 72);
275 plfFont
->lfWeight
= (SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_GETCHECK
, 0, 0) == 1) ? FW_BOLD
: FW_NORMAL
;
276 plfFont
->lfItalic
= (BYTE
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_GETCHECK
, 0, 0);
277 GetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
, LF_FACESIZE
);
280 ReleaseDC(hwndDlg
, hdcDlg
);
284 /* Select a color using a color picker */
286 GetColor(HWND hwndDlg
, GLOBALS
* g
, INT nButton
)
289 COLORREF crCustom
[16] = { 0 };
294 /* Get the color index from the element index and button number */
298 ColorIndex
= g_Assignment
[g
->CurrentElement
].Color1
;
299 ID
= IDC_ADVAPPEARANCE_COLOR1_B
;
303 ColorIndex
= g_Assignment
[g
->CurrentElement
].Color2
;
304 ID
= IDC_ADVAPPEARANCE_COLOR2_B
;
308 ColorIndex
= g_Assignment
[g
->CurrentElement
].FontColor
;
309 ID
= IDC_ADVAPPEARANCE_FONTCOLOR_B
;
313 crColor
= g
->SchemeAdv
.crColor
[ColorIndex
];
315 /* Prepare cc structure */
316 cc
.lStructSize
= sizeof(CHOOSECOLOR
);
317 cc
.hwndOwner
= hwndDlg
;
319 cc
.rgbResult
= crColor
;
320 cc
.lpCustColors
= crCustom
;
321 cc
.Flags
= CC_ANYCOLOR
| CC_FULLOPEN
| CC_RGBINIT
;
324 cc
.lpTemplateName
= NULL
;
326 /* Create the colorpicker */
327 if (ChooseColor(&cc
))
329 g
->SchemeAdv
.crColor
[ColorIndex
] = cc
.rgbResult
;
330 if (crColor
!= cc
.rgbResult
)
332 UpdateButtonColor(hwndDlg
, g
, ID
, nButton
, ColorIndex
);
333 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
342 /* Initialize the advanced appearance dialog */
344 AdvAppearanceDlg_Init(HWND hwndDlg
, GLOBALS
*g
)
346 INT i
, iElement
, iListIndex
, iDeskIndex
= 0;
349 LOGFONT lfButtonFont
;
354 /* Copy the current theme values */
355 g
->SchemeAdv
= g
->Scheme
;
357 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
359 /* Add the elements to the combo */
360 for (iElement
= 0; iElement
< NUM_ELEMENTS
; iElement
++)
362 LoadString(hApplet
, IDS_ELEMENT_0
+ iElement
, (LPTSTR
)&tstrText
, 79);
363 iListIndex
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_ADDSTRING
, 0, (LPARAM
)&tstrText
);
364 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_SETITEMDATA
, (WPARAM
)iListIndex
, (LPARAM
)iElement
);
367 /* Get the list index of the desktop element */
368 for (iListIndex
= 0; iListIndex
< NUM_ELEMENTS
; iListIndex
++)
370 iElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, (WPARAM
)iListIndex
, 0);
373 iDeskIndex
= iListIndex
;
378 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_SETCURSEL
, iDeskIndex
, 0);
380 /* Create font for bold button */
381 lfButtonFont
= g
->Scheme
.ncMetrics
.lfMessageFont
;
382 lfButtonFont
.lfWeight
= FW_BOLD
;
383 lfButtonFont
.lfItalic
= FALSE
;
384 hMyFont
= CreateFontIndirect(&lfButtonFont
);
388 DeleteObject(g
->hBoldFont
);
390 g
->hBoldFont
= hMyFont
;
393 /* Create font for italic button */
394 lfButtonFont
.lfWeight
= FW_REGULAR
;
395 lfButtonFont
.lfItalic
= TRUE
;
396 hMyFont
= CreateFontIndirect(&lfButtonFont
);
400 DeleteObject(g
->hItalicFont
);
402 g
->hItalicFont
= hMyFont
;
405 /* Set the fonts for the font style buttons */
406 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, WM_SETFONT
, (WPARAM
)g
->hBoldFont
, (LPARAM
)TRUE
);
407 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, WM_SETFONT
, (WPARAM
)g
->hItalicFont
, (LPARAM
)TRUE
);
409 /* Draw Bitmaps for the colorbuttons */
410 InitColorButtons(hwndDlg
, g
);
412 /* Make the UpDown control count correctly */
413 SendMessage(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
), UDM_SETRANGE
, 0L, MAKELONG (200, 1));
415 /* Fill font selection combo */
416 lfFont
.lfCharSet
= DEFAULT_CHARSET
;
417 lfFont
.lfFaceName
[0] = (TCHAR
)0;
418 lfFont
.lfPitchAndFamily
= 0;
419 hScreenDC
= GetDC(0);
420 EnumFontFamiliesEx(hScreenDC
, &lfFont
, (FONTENUMPROC
)EnumFontFamExProc
, (LPARAM
)GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
), 0);
421 ReleaseDC(0, hScreenDC
);
423 /* Fill font size combo */
424 for (i
= 6; i
<= 24; i
++)
426 StringCbPrintf(Size
, sizeof(Size
), TEXT("%d"), i
);
427 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, CB_ADDSTRING
, 0, (LPARAM
)&Size
);
430 /* Update the controls */
431 iListIndex
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETCURSEL
, 0, 0);
432 g
->CurrentElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, (WPARAM
)iListIndex
, 0);
433 UpdateControls(hwndDlg
, g
);
438 AdvAppearanceDlg_CleanUp(HWND hwndDlg
, GLOBALS
* g
)
440 DeleteObject(g
->hBoldFont
);
441 DeleteObject(g
->hItalicFont
);
446 SelectComboByElement(HWND hwnd
, INT id
, LPARAM lParam
)
451 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCOUNT
, 0, 0);
452 if (nCount
== CB_ERR
)
455 for (i
= 0; i
< nCount
; i
++)
457 if (SendDlgItemMessage(hwnd
, id
, CB_GETITEMDATA
, (WPARAM
)i
, 0) == lParam
)
459 SendDlgItemMessage(hwnd
, id
, CB_SETCURSEL
, (WPARAM
)i
, 0);
467 GetSelectedComboText(HWND hwnd
, INT id
, LPWSTR lpStr
)
471 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCURSEL
, 0, 0);
472 if (nCount
== CB_ERR
)
478 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETLBTEXT
, (WPARAM
)nCount
, (LPARAM
)lpStr
);
479 if (nCount
== CB_ERR
)
487 GetSelectedComboInt(HWND hwnd
, INT id
)
492 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCURSEL
, 0, 0);
493 if (nCount
== CB_ERR
)
496 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETLBTEXT
, (WPARAM
)nCount
, (LPARAM
)szBuffer
);
497 if (nCount
== CB_ERR
)
500 return _ttoi(szBuffer
);
504 AdvAppearanceDlgProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
506 INT iSelection
, iProperty
;
510 g
= (GLOBALS
*)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
515 g
= (GLOBALS
*)lParam
;
516 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)g
);
517 AdvAppearanceDlg_Init(hwndDlg
, g
);
521 AdvAppearanceDlg_CleanUp(hwndDlg
, g
);
528 switch(LOWORD(wParam
))
531 SaveCurrentValues(hwndDlg
, g
);
532 EndDialog(hwndDlg
, IDOK
);
536 g
->SchemeAdv
= g
->Scheme
;
537 EndDialog(hwndDlg
, IDCANCEL
);
540 case IDC_APPEARANCE_PREVIEW
:
541 SaveCurrentValues(hwndDlg
, g
);
542 SelectComboByElement(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, lParam
);
543 g
->CurrentElement
= (INT
)lParam
;
544 UpdateControls(hwndDlg
, g
);
547 case IDC_ADVAPPEARANCE_ELEMENT
:
548 if (HIWORD(wParam
) == CBN_SELCHANGE
)
550 SaveCurrentValues(hwndDlg
, g
);
551 iSelection
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETCURSEL
, 0, 0);
552 g
->CurrentElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, iSelection
, 0);
553 UpdateControls(hwndDlg
, g
);
557 case IDC_ADVAPPEARANCE_SIZE_E
:
558 if (HIWORD(wParam
) == EN_CHANGE
)
560 iProperty
= g_Assignment
[g
->CurrentElement
].Size
;
564 iSelection
= LOWORD(SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
, UDM_GETPOS
,0,0L));
565 SchemeSetMetric(&g
->SchemeAdv
, iProperty
, iSelection
);
566 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETSIZE
, iProperty
, iSelection
);
568 iProperty
= g_Assignment
[g
->CurrentElement
].Size2
;
570 SchemeSetMetric(&g
->SchemeAdv
, iProperty
, iSelection
);
574 case IDC_ADVAPPEARANCE_FONT_C
:
575 if (HIWORD(wParam
) == CBN_SELCHANGE
)
577 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
581 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
582 GetSelectedComboText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
);
583 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
587 case IDC_ADVAPPEARANCE_FONTSIZE_E
:
588 if ((HIWORD(wParam
) == CBN_SELCHANGE
|| HIWORD(wParam
) == CBN_EDITCHANGE
))
592 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
596 hdcDlg
= GetDC(hwndDlg
);
598 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
599 iSelection
= GetSelectedComboInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
);
600 plfFont
->lfHeight
= -MulDiv(iSelection
, GetDeviceCaps(hdcDlg
, LOGPIXELSY
), 72);
601 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
603 ReleaseDC(hwndDlg
, hdcDlg
);
607 case IDC_ADVAPPEARANCE_FONTBOLD
:
608 if (HIWORD(wParam
) == BN_CLICKED
)
610 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
614 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
615 iSelection
= (INT
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_GETCHECK
, 0, 0);
616 plfFont
->lfWeight
= (iSelection
== BST_CHECKED
) ? FW_BOLD
: FW_NORMAL
;
617 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
621 case IDC_ADVAPPEARANCE_FONTITALIC
:
622 if (HIWORD(wParam
) == BN_CLICKED
)
624 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
628 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
629 iSelection
= (INT
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_GETCHECK
, 0, 0);
630 plfFont
->lfItalic
= (iSelection
== BST_CHECKED
) ? TRUE
: FALSE
;
631 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
635 case IDC_ADVAPPEARANCE_COLOR1_B
:
636 GetColor(hwndDlg
, g
, 0);
639 case IDC_ADVAPPEARANCE_COLOR2_B
:
640 GetColor(hwndDlg
, g
, 1);
643 case IDC_ADVAPPEARANCE_FONTCOLOR_B
:
644 GetColor(hwndDlg
, g
, 2);