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
] =
29 { {-1, -1, COLOR_DESKTOP
, -1, -1, -1}, /* -Desktop */
30 {SIZE_CAPTION_HEIGHT
, -1, COLOR_INACTIVECAPTION
, COLOR_GRADIENTINACTIVECAPTION
, FONT_CAPTION
, -1}, /* inactive window caption */
31 {SIZE_BORDER_WIDTH
, -1, COLOR_INACTIVEBORDER
, -1, -1, -1}, /* inactive window border */
32 {SIZE_CAPTION_HEIGHT
, -1, COLOR_ACTIVECAPTION
, COLOR_GRADIENTACTIVECAPTION
, FONT_CAPTION
, COLOR_CAPTIONTEXT
}, /* -active window caption */
33 {SIZE_BORDER_WIDTH
, -1, COLOR_ACTIVEBORDER
, -1, -1, -1}, /* active window border */
34 {SIZE_MENU_HEIGHT
, SIZE_MENU_WIDTH
, COLOR_MENU
, -1, FONT_MENU
, COLOR_MENUTEXT
}, /* menu */
35 {SIZE_MENU_HEIGHT
, SIZE_MENU_WIDTH
, COLOR_HIGHLIGHT
, -1, -1, COLOR_HIGHLIGHTTEXT
},/* marked element */
36 {-1, -1, COLOR_WINDOW
, -1 /*COLOR_WINDOWFRAME*/, -1, COLOR_WINDOWTEXT
}, /* window */
37 {SIZE_SCROLL_WIDTH
, SIZE_SCROLL_HEIGHT
, COLOR_SCROLLBAR
, -1, -1, -1}, /* scroll bar */
38 {-1, -1, COLOR_3DFACE
, -1, -1, COLOR_BTNTEXT
}, /* 3d objects */
39 {SIZE_SM_CAPTION_HEIGHT
, -1, -1, -1, FONT_SMCAPTION
, -1}, /* palette window caption */
40 {-1, -1, -1, -1, -1, -1}, /* symbol caption FIXME: Access? */
41 {SIZE_CAPTION_HEIGHT
, -1, -1, -1, -1, -1}, /* caption bar */
42 {-1, -1, -1, -1, -1, COLOR_GRAYTEXT
}, /* inactive menu item FIXME: Access? */
43 {-1, -1, -1, -1, FONT_MESSAGE
, COLOR_WINDOWTEXT
}, /* dialog */
44 {-1, -1, -1, -1, -1, -1}, /* scrollbar controls FIXME: Access? */
45 {-1, -1, COLOR_APPWORKSPACE
, -1, -1, -1}, /* application background */
46 {-1, -1, -1, -1, -1, -1}, /* small caption bar FIXME: Access? */
47 {SIZE_ICON_SPACE_X
, -1, -1, -1, -1, -1}, /* symbol distance horiz. */
48 {SIZE_ICON_SPACE_Y
, -1, -1, -1, -1, -1}, /* symbol distance vert. */
49 {-1, -1, COLOR_INFOBK
, -1, FONT_STATUS
, COLOR_INFOTEXT
}, /* quickinfo */
50 {SIZE_ICON
, -1, -1, -1, FONT_ICON
, -1}}; /* symbol */
52 /******************************************************************************/
54 /* Draw the current color on the color picker buttons */
56 UpdateButtonColor(HWND hwndDlg
, GLOBALS
* g
, INT ID
, INT nButton
, INT nColor
)
58 HDC hdcColorButton
, hdcCompat
;
66 /* Create a DC to draw on */
67 hwndColorButton
= GetDlgItem(hwndDlg
, ID
);
68 hdcColorButton
= GetDC(hwndColorButton
);
69 hdcCompat
= CreateCompatibleDC(hdcColorButton
);
70 ReleaseDC(hwndColorButton
, hdcColorButton
);
72 /* Select the button image to it */
73 hgdiTmp
= SelectObject(hdcCompat
, g
->hbmpColor
[nButton
]);
75 /* Create a brush and draw the rectangle */
80 hbrush
= CreateSolidBrush(g
->SchemeAdv
.crColor
[nColor
]);
81 FillRect(hdcCompat
, &rect
, hbrush
);
84 /* hdcCompat is not needed anymore */
85 SelectObject(hdcCompat
,hgdiTmp
);
88 SendDlgItemMessage(hwndDlg
, ID
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[nButton
]);
89 EnableWindow(GetDlgItem(hwndDlg
, ID
), TRUE
);
93 SendDlgItemMessage(hwndDlg
, ID
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)NULL
);
94 EnableWindow(GetDlgItem(hwndDlg
, ID
), FALSE
);
99 /* Create the basic bitmaps for the color picker buttons */
101 InitColorButtons(HWND hwndDlg
, GLOBALS
* g
)
104 HDC hdcColorButton
, hdcCompat
;
108 HWND hwndColorButton
;
110 COLOR_SCHEME
*scheme
= &g
->SchemeAdv
;
112 const POINT Points
[3] = {{29,6},{33,6},{31,8}};
114 hwndColorButton
= GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_B
);
115 hdcColorButton
= GetDC(hwndColorButton
);
116 for (i
= 0; i
<= 2; i
++)
118 /* Create a DC to draw on */
119 hdcCompat
= CreateCompatibleDC(hdcColorButton
);
121 /* Create the button image */
122 g
->hbmpColor
[i
] = CreateCompatibleBitmap(hdcColorButton
, 36, 15);
124 /* Select the button image to the DC */
125 hgdiTemp
= SelectObject(hdcCompat
, g
->hbmpColor
[i
]);
127 /* Draw the buttons background color */
132 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNFACE
]);
133 FillRect(hdcCompat
, &rect
, hbrush
);
134 DeleteObject(hbrush
);
136 /* Draw the rectangle */
141 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNTEXT
]);
142 FillRect(hdcCompat
, &rect
, hbrush
);
143 DeleteObject(hbrush
);
145 /* Draw left side of line */
146 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNSHADOW
]);
147 SelectObject(hdcCompat
, hPen
);
148 MoveToEx(hdcCompat
, 26, 1, NULL
);
149 LineTo(hdcCompat
, 26, 14);
150 SelectObject(hdcCompat
, GetStockObject(BLACK_PEN
));
153 /* Draw right side of line */
154 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNHIGHLIGHT
]);
155 SelectObject(hdcCompat
,hPen
);
156 MoveToEx(hdcCompat
, 27, 1, NULL
);
157 LineTo(hdcCompat
, 27, 14);
158 SelectObject(hdcCompat
, GetStockObject(BLACK_PEN
));
162 hPen
= CreatePen(PS_SOLID
, 1, scheme
->crColor
[COLOR_BTNTEXT
]);
163 hbrush
= CreateSolidBrush(scheme
->crColor
[COLOR_BTNTEXT
]);
164 SelectObject(hdcCompat
, hPen
);
165 SelectObject(hdcCompat
, hbrush
);
166 SetPolyFillMode(hdcCompat
, WINDING
);
168 /* FIXME: HACK, see Points definition */
169 Polygon(hdcCompat
, Points
, 3);
172 SelectObject(hdcCompat
,hgdiTemp
);
175 DeleteObject(hbrush
);
178 ReleaseDC(hwndColorButton
, hdcColorButton
);
180 /* Set the images of the buttons */
181 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[0]);
182 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_COLOR2_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[1]);
183 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTCOLOR_B
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)g
->hbmpColor
[2]);
187 /* This is the callback function to add the installed fonts to the font combo */
189 EnumFontFamExProc(ENUMLOGFONTEX
*lpelfe
, NEWTEXTMETRICEX
*lpntme
, DWORD dwFontType
, LPARAM lParam
)
191 /* Don't enumerate more than 100 fonts */
192 if (SendMessage((HWND
)lParam
, CB_GETCOUNT
, 0, 0) >= 100)
195 /* Only add the string once */
196 if (SendMessage((HWND
)lParam
, CB_FINDSTRINGEXACT
, -1, (WPARAM
)&(lpelfe
->elfLogFont
.lfFaceName
)) != CB_ERR
)
199 SendMessage((HWND
)lParam
, CB_ADDSTRING
, 0, (WPARAM
)&(lpelfe
->elfLogFont
.lfFaceName
));
205 /* Update all the controls with the current values for the selected screen element */
207 UpdateControls(HWND hwndDlg
, GLOBALS
*g
)
212 iElement
= g
->CurrentElement
;
214 /* First enable / disable the controls */
215 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
), (g_Assignment
[iElement
].Size
!= -1));
216 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
), (g_Assignment
[iElement
].Size
!= -1));
217 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_T
), (g_Assignment
[iElement
].Size
!= -1));
218 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR1_T
), (g_Assignment
[iElement
].Color1
!= -1));
219 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_COLOR2_T
), (g_Assignment
[iElement
].Color2
!= -1));
220 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_T
), (g_Assignment
[iElement
].Font
!= -1));
221 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
), (g_Assignment
[iElement
].Font
!= -1));
222 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_T
), (g_Assignment
[iElement
].Font
!= -1));
223 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
), (g_Assignment
[iElement
].Font
!= -1));
224 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTCOLOR_T
), (g_Assignment
[iElement
].FontColor
!= -1));
225 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
), (g_Assignment
[iElement
].Font
!= -1));
226 EnableWindow(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
), (g_Assignment
[iElement
].Font
!= -1));
228 /* Update the colors of the color buttons */
229 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_COLOR1_B
, 0, g_Assignment
[iElement
].Color1
);
230 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_COLOR2_B
, 1, g_Assignment
[iElement
].Color2
);
231 UpdateButtonColor(hwndDlg
, g
, IDC_ADVAPPEARANCE_FONTCOLOR_B
, 2, g_Assignment
[iElement
].FontColor
);
233 if (g_Assignment
[iElement
].Size
!= -1)
234 SetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, SchemeGetMetric(&g
->SchemeAdv
, g_Assignment
[iElement
].Size
), FALSE
);
236 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, TEXT(""));
238 hdcDlg
= GetDC(hwndDlg
);
239 if (g_Assignment
[iElement
].Font
!= -1)
241 PLOGFONTW plfFont
= SchemeGetFont(&g
->SchemeAdv
, g_Assignment
[iElement
].Font
);
243 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
);
244 SetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, -MulDiv(plfFont
->lfHeight
, 72, GetDeviceCaps(hdcDlg
, LOGPIXELSY
)),FALSE
);
245 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, CB_FINDSTRINGEXACT
, -1, (WPARAM
)plfFont
->lfFaceName
);
246 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_SETCHECK
, plfFont
->lfWeight
== FW_BOLD
?1:0, 0);
247 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_SETCHECK
, plfFont
->lfItalic
, 0);
251 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, NULL
);
252 SetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, NULL
);
253 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_SETCHECK
, 0, 0);
254 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_SETCHECK
, 0, 0);
257 ReleaseDC(hwndDlg
, hdcDlg
);
262 SaveCurrentValues(HWND hwndDlg
, GLOBALS
*g
)
265 HDC hdcDlg
= GetDC(hwndDlg
);
267 if (g_Assignment
[g
->CurrentElement
].Size
!= -1)
269 SchemeSetMetric(&g
->SchemeAdv
, g_Assignment
[g
->CurrentElement
].Size
, GetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_E
, &bTranslated
, FALSE
));
272 if (g_Assignment
[g
->CurrentElement
].Font
!= -1)
274 PLOGFONTW plfFont
= SchemeGetFont(&g
->SchemeAdv
, g_Assignment
[g
->CurrentElement
].Font
);
275 plfFont
->lfHeight
= -MulDiv(GetDlgItemInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, &bTranslated
, FALSE
), GetDeviceCaps(hdcDlg
, LOGPIXELSY
), 72);
276 plfFont
->lfWeight
= (SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_GETCHECK
, 0, 0) == 1) ? FW_BOLD
: FW_NORMAL
;
277 plfFont
->lfItalic
= (BYTE
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_GETCHECK
, 0, 0);
278 GetDlgItemText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
, LF_FACESIZE
);
281 ReleaseDC(hwndDlg
, hdcDlg
);
285 /* Select a color using a color picker */
287 GetColor(HWND hwndDlg
, GLOBALS
* g
, INT nButton
)
290 COLORREF crCustom
[16] = { 0 };
295 /* Get the color index from the element index and button number */
299 ColorIndex
= g_Assignment
[g
->CurrentElement
].Color1
;
300 ID
= IDC_ADVAPPEARANCE_COLOR1_B
;
304 ColorIndex
= g_Assignment
[g
->CurrentElement
].Color2
;
305 ID
= IDC_ADVAPPEARANCE_COLOR2_B
;
309 ColorIndex
= g_Assignment
[g
->CurrentElement
].FontColor
;
310 ID
= IDC_ADVAPPEARANCE_FONTCOLOR_B
;
314 crColor
= g
->SchemeAdv
.crColor
[ColorIndex
];
316 /* Prepare cc structure */
317 cc
.lStructSize
= sizeof(CHOOSECOLOR
);
318 cc
.hwndOwner
= hwndDlg
;
320 cc
.rgbResult
= crColor
;
321 cc
.lpCustColors
= crCustom
;
322 cc
.Flags
= CC_ANYCOLOR
| CC_FULLOPEN
| CC_RGBINIT
;
325 cc
.lpTemplateName
= NULL
;
327 /* Create the colorpicker */
328 if (ChooseColor(&cc
))
330 g
->SchemeAdv
.crColor
[ColorIndex
] = cc
.rgbResult
;
331 if (crColor
!= cc
.rgbResult
)
333 UpdateButtonColor(hwndDlg
, g
, ID
, nButton
, ColorIndex
);
334 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
343 /* Initialize the advanced appearance dialog */
345 AdvAppearanceDlg_Init(HWND hwndDlg
, GLOBALS
*g
)
347 INT i
, iElement
, iListIndex
, iDeskIndex
= 0;
350 LOGFONT lfButtonFont
;
355 /* Copy the current theme values */
356 g
->SchemeAdv
= g
->Scheme
;
358 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
361 /* Add the elements to the combo */
362 for (iElement
= 0; iElement
< NUM_ELEMENTS
; iElement
++)
364 LoadString(hApplet
, IDS_ELEMENT_1
+ iElement
, (LPTSTR
)&tstrText
, 79);
365 iListIndex
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_ADDSTRING
, 0, (LPARAM
)&tstrText
);
366 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_SETITEMDATA
, (WPARAM
)iListIndex
, (LPARAM
)iElement
);
369 /* Get the list index of the desktop element */
370 for (iListIndex
= 0; iListIndex
< NUM_ELEMENTS
; iListIndex
++)
372 iElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, (WPARAM
)iListIndex
, 0);
375 iDeskIndex
= iListIndex
;
380 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_SETCURSEL
, iDeskIndex
, 0);
382 /* Create font for bold button */
383 lfButtonFont
= g
->Scheme
.ncMetrics
.lfMessageFont
;
384 lfButtonFont
.lfWeight
= FW_BOLD
;
385 lfButtonFont
.lfItalic
= FALSE
;
386 hMyFont
= CreateFontIndirect(&lfButtonFont
);
390 DeleteObject(g
->hBoldFont
);
392 g
->hBoldFont
= hMyFont
;
395 /* Create font for italic button */
396 lfButtonFont
.lfWeight
= FW_REGULAR
;
397 lfButtonFont
.lfItalic
= TRUE
;
398 hMyFont
= CreateFontIndirect(&lfButtonFont
);
402 DeleteObject(g
->hItalicFont
);
404 g
->hItalicFont
= hMyFont
;
407 /* Set the fonts for the font style buttons */
408 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, WM_SETFONT
, (WPARAM
)g
->hBoldFont
, (LPARAM
)TRUE
);
409 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, WM_SETFONT
, (WPARAM
)g
->hItalicFont
, (LPARAM
)TRUE
);
411 /* Draw Bitmaps for the colorbuttons */
412 InitColorButtons(hwndDlg
, g
);
414 /* Make the UpDown control count correctly */
415 SendMessage(GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
), UDM_SETRANGE
, 0L, MAKELONG (200, 1));
417 /* Fill font selection combo */
418 lfFont
.lfCharSet
= DEFAULT_CHARSET
;
419 lfFont
.lfFaceName
[0] = (TCHAR
)0;
420 lfFont
.lfPitchAndFamily
= 0;
421 hScreenDC
= GetDC(0);
422 EnumFontFamiliesEx(hScreenDC
, &lfFont
, (FONTENUMPROC
)EnumFontFamExProc
, (LPARAM
)GetDlgItem(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
), 0);
423 ReleaseDC(0, hScreenDC
);
425 /* Fill font size combo */
426 for (i
= 6; i
<= 24; i
++)
428 StringCbPrintf(Size
, sizeof(Size
), TEXT("%d"), i
);
429 SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
, CB_ADDSTRING
, 0, (LPARAM
)&Size
);
432 /* Update the controls */
433 iListIndex
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETCURSEL
, 0, 0);
434 g
->CurrentElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, (WPARAM
)iListIndex
, 0);
435 UpdateControls(hwndDlg
, g
);
440 AdvAppearanceDlg_CleanUp(HWND hwndDlg
, GLOBALS
* g
)
442 DeleteObject(g
->hBoldFont
);
443 DeleteObject(g
->hItalicFont
);
448 SelectComboByElement(HWND hwnd
, INT id
, LPARAM lParam
)
453 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCOUNT
, 0, 0);
454 if (nCount
== CB_ERR
)
457 for (i
= 0; i
< nCount
; i
++)
459 if (SendDlgItemMessage(hwnd
, id
, CB_GETITEMDATA
, (WPARAM
)i
, 0) == lParam
)
461 SendDlgItemMessage(hwnd
, id
, CB_SETCURSEL
, (WPARAM
)i
, 0);
469 GetSelectedComboText(HWND hwnd
, INT id
, LPWSTR lpStr
)
473 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCURSEL
, 0, 0);
474 if (nCount
== CB_ERR
)
480 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETLBTEXT
, (WPARAM
)nCount
, (LPARAM
)lpStr
);
481 if (nCount
== CB_ERR
)
489 GetSelectedComboInt(HWND hwnd
, INT id
)
494 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETCURSEL
, 0, 0);
495 if (nCount
== CB_ERR
)
498 nCount
= SendDlgItemMessage(hwnd
, id
, CB_GETLBTEXT
, (WPARAM
)nCount
, (LPARAM
)szBuffer
);
499 if (nCount
== CB_ERR
)
502 return _ttoi(szBuffer
);
506 AdvAppearanceDlgProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
508 INT iSelection
, iProperty
;
512 g
= (GLOBALS
*)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
517 g
= (GLOBALS
*)lParam
;
518 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)g
);
519 AdvAppearanceDlg_Init(hwndDlg
, g
);
523 AdvAppearanceDlg_CleanUp(hwndDlg
, g
);
530 switch(LOWORD(wParam
))
533 SaveCurrentValues(hwndDlg
, g
);
534 EndDialog(hwndDlg
, IDOK
);
538 g
->SchemeAdv
= g
->Scheme
;
539 EndDialog(hwndDlg
, IDCANCEL
);
542 case IDC_APPEARANCE_PREVIEW
:
543 SaveCurrentValues(hwndDlg
, g
);
544 SelectComboByElement(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, lParam
);
545 g
->CurrentElement
= (INT
)lParam
;
546 UpdateControls(hwndDlg
, g
);
549 case IDC_ADVAPPEARANCE_ELEMENT
:
550 if (HIWORD(wParam
) == CBN_SELCHANGE
)
552 SaveCurrentValues(hwndDlg
, g
);
553 iSelection
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETCURSEL
, 0, 0);
554 g
->CurrentElement
= SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_ELEMENT
, CB_GETITEMDATA
, iSelection
, 0);
555 UpdateControls(hwndDlg
, g
);
559 case IDC_ADVAPPEARANCE_SIZE_E
:
560 if (HIWORD(wParam
) == EN_CHANGE
)
562 iProperty
= g_Assignment
[g
->CurrentElement
].Size
;
566 iSelection
= LOWORD(SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_SIZE_UD
, UDM_GETPOS
,0,0L));
567 SchemeSetMetric(&g
->SchemeAdv
, iProperty
, iSelection
);
568 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETSIZE
, iProperty
, iSelection
);
570 iProperty
= g_Assignment
[g
->CurrentElement
].Size2
;
572 SchemeSetMetric(&g
->SchemeAdv
, iProperty
, iSelection
);
576 case IDC_ADVAPPEARANCE_FONT_C
:
577 if (HIWORD(wParam
) == CBN_SELCHANGE
)
579 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
583 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
584 GetSelectedComboText(hwndDlg
, IDC_ADVAPPEARANCE_FONT_C
, plfFont
->lfFaceName
);
585 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
589 case IDC_ADVAPPEARANCE_FONTSIZE_E
:
590 if ((HIWORD(wParam
) == CBN_SELCHANGE
|| HIWORD(wParam
) == CBN_EDITCHANGE
))
594 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
598 hdcDlg
= GetDC(hwndDlg
);
600 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
601 iSelection
= GetSelectedComboInt(hwndDlg
, IDC_ADVAPPEARANCE_FONTSIZE_E
);
602 plfFont
->lfHeight
= -MulDiv(iSelection
, GetDeviceCaps(hdcDlg
, LOGPIXELSY
), 72);
603 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_UPDATETHEME
, 0, (LPARAM
)&g
->SchemeAdv
);
605 ReleaseDC(hwndDlg
, hdcDlg
);
609 case IDC_ADVAPPEARANCE_FONTBOLD
:
610 if (HIWORD(wParam
) == BN_CLICKED
)
612 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
616 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
617 iSelection
= (INT
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTBOLD
, BM_GETCHECK
, 0, 0);
618 plfFont
->lfWeight
= (iSelection
== BST_CHECKED
) ? FW_BOLD
: FW_NORMAL
;
619 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
623 case IDC_ADVAPPEARANCE_FONTITALIC
:
624 if (HIWORD(wParam
) == BN_CLICKED
)
626 iProperty
= g_Assignment
[g
->CurrentElement
].Font
;
630 plfFont
= SchemeGetFont(&g
->SchemeAdv
, iProperty
);
631 iSelection
= (INT
)SendDlgItemMessage(hwndDlg
, IDC_ADVAPPEARANCE_FONTITALIC
, BM_GETCHECK
, 0, 0);
632 plfFont
->lfItalic
= (iSelection
== BST_CHECKED
) ? TRUE
: FALSE
;
633 SendDlgItemMessage(hwndDlg
, IDC_APPEARANCE_PREVIEW
, PVM_SETFONT
, iProperty
, (LPARAM
)plfFont
);
637 case IDC_ADVAPPEARANCE_COLOR1_B
:
638 GetColor(hwndDlg
, g
, 0);
641 case IDC_ADVAPPEARANCE_COLOR2_B
:
642 GetColor(hwndDlg
, g
, 1);
645 case IDC_ADVAPPEARANCE_FONTCOLOR_B
:
646 GetColor(hwndDlg
, g
, 2);