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