2 * COMMDLG - Font Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/winbase16.h"
31 #include "wine/winuser16.h"
35 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
42 static HBITMAP hBitmapTT
= 0;
45 INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
47 INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
49 BOOL16 CALLBACK
FormatCharDlgProc16(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
52 /* There is a table here of all charsets, and the sample text for each.
53 * There is a second table that translates a charset into an index into
57 #define CI(cs) ((IDS_CHARSET_##cs)-IDS_CHARSET_ANSI)
58 #define SAMPLE_EXTLEN 10
60 static const WCHAR SAMPLE_LANG_TEXT
[][SAMPLE_EXTLEN
]={
61 {'Y','y','Z','z',0}, /* Western and default */
69 {0x05e0, 0x05e1, 0x05e9, 0x05ea, 0}, /* Hebrew */
74 {0}, /* East European */
84 {0}, /* ISO-8859-10 */
88 static const int CHARSET_ORDER
[256]={
89 CI(ANSI
), 0, CI(SYMBOL
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(MAC
), 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 CI(JIS
), CI(HANGUL
), CI(JOHAB
), 0, 0, 0, CI(GB2312
), 0, CI(BIG5
), 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99 0, CI(GREEK
), CI(TURKISH
), CI(VIETNAMESE
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 0, CI(HEBREW
), CI(ARABIC
), 0, 0, 0, 0, 0, 0, 0, CI(BALTIC
), 0, 0, 0, 0, 0,
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(RUSSIAN
), 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(THAI
), 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(EE
), 0,
104 CI(VISCII
), CI(TCVN
), CI(KOI8
), CI(ISO3
), CI(ISO4
), CI(ISO10
), CI(CELTIC
), 0, 0, 0, 0, 0, 0, 0, 0, CI(OEM
),
107 static void FONT_LogFont16To32A( const LPLOGFONT16 font16
, LPLOGFONTA font32
)
109 font32
->lfHeight
= font16
->lfHeight
;
110 font32
->lfWidth
= font16
->lfWidth
;
111 font32
->lfEscapement
= font16
->lfEscapement
;
112 font32
->lfOrientation
= font16
->lfOrientation
;
113 font32
->lfWeight
= font16
->lfWeight
;
114 font32
->lfItalic
= font16
->lfItalic
;
115 font32
->lfUnderline
= font16
->lfUnderline
;
116 font32
->lfStrikeOut
= font16
->lfStrikeOut
;
117 font32
->lfCharSet
= font16
->lfCharSet
;
118 font32
->lfOutPrecision
= font16
->lfOutPrecision
;
119 font32
->lfClipPrecision
= font16
->lfClipPrecision
;
120 font32
->lfQuality
= font16
->lfQuality
;
121 font32
->lfPitchAndFamily
= font16
->lfPitchAndFamily
;
122 lstrcpynA( font32
->lfFaceName
, font16
->lfFaceName
, LF_FACESIZE
);
125 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16
, LPCHOOSEFONTA chf32a
)
127 chf32a
->lStructSize
=sizeof(CHOOSEFONTA
);
128 chf32a
->hwndOwner
=HWND_32(chf16
->hwndOwner
);
129 chf32a
->hDC
=HDC_32(chf16
->hDC
);
130 chf32a
->iPointSize
=chf16
->iPointSize
;
131 chf32a
->Flags
=chf16
->Flags
;
132 chf32a
->rgbColors
=chf16
->rgbColors
;
133 chf32a
->lCustData
=chf16
->lCustData
;
134 chf32a
->lpfnHook
=NULL
;
135 chf32a
->lpTemplateName
=MapSL(chf16
->lpTemplateName
);
136 chf32a
->hInstance
=HINSTANCE_32(chf16
->hInstance
);
137 chf32a
->lpszStyle
=MapSL(chf16
->lpszStyle
);
138 chf32a
->nFontType
=chf16
->nFontType
;
139 chf32a
->nSizeMax
=chf16
->nSizeMax
;
140 chf32a
->nSizeMin
=chf16
->nSizeMin
;
141 FONT_LogFont16To32A(MapSL(chf16
->lpLogFont
), chf32a
->lpLogFont
);
148 #define XX(x) { x, #x },
153 XX(CF_ENABLETEMPLATE
)
154 XX(CF_ENABLETEMPLATEHANDLE
)
155 XX(CF_INITTOLOGFONTSTRUCT
)
163 XX(CF_FIXEDPITCHONLY
)
165 XX(CF_FORCEFONTEXIST
)
179 _dump_cf_flags(DWORD cflags
) {
182 for (i
=0;cfflags
[i
].name
;i
++)
183 if (cfflags
[i
].mask
& cflags
)
184 MESSAGE("%s|",cfflags
[i
].name
);
189 /***********************************************************************
190 * ChooseFont (COMMDLG.15)
192 BOOL16 WINAPI
ChooseFont16(LPCHOOSEFONT16 lpChFont
)
195 HANDLE16 hDlgTmpl16
= 0, hResource16
= 0;
196 HGLOBAL16 hGlobal16
= 0;
203 SEGPTR lpTemplateName
;
205 cf32a
.lpLogFont
=&lf32a
;
206 CFn_CHOOSEFONT16to32A(lpChFont
, &cf32a
);
208 TRACE("ChooseFont\n");
209 if (!lpChFont
) return FALSE
;
211 if (TRACE_ON(commdlg
))
212 _dump_cf_flags(lpChFont
->Flags
);
214 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
216 if (!(template = LockResource16( lpChFont
->hInstance
)))
218 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
222 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
225 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
226 MapSL(lpChFont
->lpTemplateName
),
229 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
232 if (!(hDlgTmpl16
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
233 !(template = LockResource16( hDlgTmpl16
)))
235 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
245 if (!(hResInfo
= FindResourceA(COMDLG32_hInstance
, "CHOOSE_FONT", RT_DIALOGA
)))
247 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
250 if (!(hDlgTmpl32
= LoadResource(COMDLG32_hInstance
, hResInfo
)) ||
251 !(template32
= LockResource(hDlgTmpl32
)))
253 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
256 size
= SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo
);
257 hGlobal16
= GlobalAlloc16(0, size
);
260 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE
);
261 ERR("alloc failure for %ld bytes\n", size
);
264 template = GlobalLock16(hGlobal16
);
267 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE
);
268 ERR("global lock failure for %x handle\n", hGlobal16
);
269 GlobalFree16(hGlobal16
);
272 ConvertDialog32To16((LPVOID
)template32
, size
, (LPVOID
)template);
273 hDlgTmpl16
= hGlobal16
;
277 /* lpTemplateName is not used in the dialog */
278 lpTemplateName
=lpChFont
->lpTemplateName
;
279 lpChFont
->lpTemplateName
=(SEGPTR
)&cf32a
;
281 ptr
= GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR
) 16);
282 hInst
= GetWindowLongA(HWND_32(lpChFont
->hwndOwner
), GWL_HINSTANCE
);
283 bRet
= DialogBoxIndirectParam16(hInst
, hDlgTmpl16
, lpChFont
->hwndOwner
,
284 (DLGPROC16
) ptr
, (DWORD
)lpChFont
);
285 if (hResource16
) FreeResource16(hDlgTmpl16
);
288 GlobalUnlock16(hGlobal16
);
289 GlobalFree16(hGlobal16
);
291 lpChFont
->lpTemplateName
=lpTemplateName
;
294 font16
= MapSL(lpChFont
->lpLogFont
);
295 font16
->lfHeight
= cf32a
.lpLogFont
->lfHeight
;
296 font16
->lfWidth
= cf32a
.lpLogFont
->lfWidth
;
297 font16
->lfEscapement
= cf32a
.lpLogFont
->lfEscapement
;
298 font16
->lfOrientation
= cf32a
.lpLogFont
->lfOrientation
;
299 font16
->lfWeight
= cf32a
.lpLogFont
->lfWeight
;
300 font16
->lfItalic
= cf32a
.lpLogFont
->lfItalic
;
301 font16
->lfUnderline
= cf32a
.lpLogFont
->lfUnderline
;
302 font16
->lfStrikeOut
= cf32a
.lpLogFont
->lfStrikeOut
;
303 font16
->lfCharSet
= cf32a
.lpLogFont
->lfCharSet
;
304 font16
->lfOutPrecision
= cf32a
.lpLogFont
->lfOutPrecision
;
305 font16
->lfClipPrecision
= cf32a
.lpLogFont
->lfClipPrecision
;
306 font16
->lfQuality
= cf32a
.lpLogFont
->lfQuality
;
307 font16
->lfPitchAndFamily
= cf32a
.lpLogFont
->lfPitchAndFamily
;
308 lstrcpynA( font16
->lfFaceName
, cf32a
.lpLogFont
->lfFaceName
, LF_FACESIZE
);
313 /***********************************************************************
314 * ChooseFontA (COMDLG32.@)
316 BOOL WINAPI
ChooseFontA(LPCHOOSEFONTA lpChFont
)
323 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATEHANDLE
)!=0 )
325 template=(LPCVOID
)lpChFont
->hInstance
;
328 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATE
)!=0 )
330 hDlginst
=lpChFont
->hInstance
;
331 if( !(hResInfo
= FindResourceA(hDlginst
, lpChFont
->lpTemplateName
,
334 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
339 hDlginst
=COMDLG32_hInstance
;
340 if (!(hResInfo
= FindResourceA(hDlginst
, "CHOOSE_FONT", RT_DIALOGA
)))
342 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
346 if (!(hDlgTmpl
= LoadResource(hDlginst
, hResInfo
)) ||
347 !(template = LockResource( hDlgTmpl
)))
349 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
353 if (TRACE_ON(commdlg
))
354 _dump_cf_flags(lpChFont
->Flags
);
356 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
))
357 FIXME(": unimplemented flag (ignored)\n");
359 return DialogBoxIndirectParamA(COMDLG32_hInstance
, template,
360 lpChFont
->hwndOwner
, FormatCharDlgProcA
, (LPARAM
)lpChFont
);
363 /***********************************************************************
364 * ChooseFontW (COMDLG32.@)
368 * The LOGFONT conversion functions will break if the structure ever
369 * grows beyond the lfFaceName element.
371 * The CHOOSEFONT conversion functions assume that both versions of
372 * lpLogFont and lpszStyle (if used) point to pre-allocated objects.
374 * The ASCII version of lpTemplateName is created by ChooseFontAtoW
375 * and freed by ChooseFontWtoA.
377 inline static VOID
LogFontWtoA(const LOGFONTW
*lfw
, LOGFONTA
*lfa
)
379 memcpy(lfa
, lfw
, sizeof(LOGFONTA
));
380 WideCharToMultiByte(CP_ACP
, 0, lfw
->lfFaceName
, -1, lfa
->lfFaceName
,
381 LF_FACESIZE
, NULL
, NULL
);
382 lfa
->lfFaceName
[LF_FACESIZE
- 1] = '\0';
385 inline static VOID
LogFontAtoW(const LOGFONTA
*lfa
, LOGFONTW
*lfw
)
387 memcpy(lfw
, lfa
, sizeof(LOGFONTA
));
388 MultiByteToWideChar(CP_ACP
, 0, lfa
->lfFaceName
, -1, lfw
->lfFaceName
,
390 lfw
->lfFaceName
[LF_FACESIZE
- 1] = 0;
393 static BOOL
ChooseFontWtoA(const CHOOSEFONTW
*cfw
, CHOOSEFONTA
*cfa
)
395 LOGFONTA
*lpLogFont
= cfa
->lpLogFont
;
396 LPSTR lpszStyle
= cfa
->lpszStyle
;
398 memcpy(cfa
, cfw
, sizeof(CHOOSEFONTA
));
399 cfa
->lpLogFont
= lpLogFont
;
400 cfa
->lpszStyle
= lpszStyle
;
402 LogFontWtoA(cfw
->lpLogFont
, lpLogFont
);
404 if ((cfw
->Flags
&CF_ENABLETEMPLATE
)!=0 && HIWORD(cfw
->lpTemplateName
)!=0)
406 cfa
->lpTemplateName
= HEAP_strdupWtoA(GetProcessHeap(), 0,
407 cfw
->lpTemplateName
);
408 if (cfa
->lpTemplateName
== NULL
)
412 if ((cfw
->Flags
& CF_USESTYLE
) != 0 && cfw
->lpszStyle
!= NULL
)
414 WideCharToMultiByte(CP_ACP
, 0, cfw
->lpszStyle
, -1, cfa
->lpszStyle
,
415 LF_FACESIZE
, NULL
, NULL
);
416 cfa
->lpszStyle
[LF_FACESIZE
- 1] = '\0';
422 static VOID
ChooseFontAtoW(const CHOOSEFONTA
*cfa
, CHOOSEFONTW
*cfw
)
424 LOGFONTW
*lpLogFont
= cfw
->lpLogFont
;
425 LPWSTR lpszStyle
= cfw
->lpszStyle
;
426 LPCWSTR lpTemplateName
= cfw
->lpTemplateName
;
428 memcpy(cfw
, cfa
, sizeof(CHOOSEFONTA
));
429 cfw
->lpLogFont
= lpLogFont
;
430 cfw
->lpszStyle
= lpszStyle
;
431 cfw
->lpTemplateName
= lpTemplateName
;
433 LogFontAtoW(cfa
->lpLogFont
, lpLogFont
);
435 if ((cfa
->Flags
&CF_ENABLETEMPLATE
)!=0 && HIWORD(cfa
->lpTemplateName
) != 0)
436 HeapFree(GetProcessHeap(), 0, (LPSTR
)(cfa
->lpTemplateName
));
438 if ((cfa
->Flags
& CF_USESTYLE
) != 0 && cfa
->lpszStyle
!= NULL
)
440 MultiByteToWideChar(CP_ACP
, 0, cfa
->lpszStyle
, -1, cfw
->lpszStyle
,
442 cfw
->lpszStyle
[LF_FACESIZE
- 1] = 0;
446 BOOL WINAPI
ChooseFontW(LPCHOOSEFONTW lpChFont
)
450 CHAR style_a
[LF_FACESIZE
];
452 cf_a
.lpLogFont
= &lf_a
;
453 cf_a
.lpszStyle
= style_a
;
455 if (ChooseFontWtoA(lpChFont
, &cf_a
) == FALSE
)
457 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE
);
461 if (ChooseFontA(&cf_a
) == FALSE
)
463 if (cf_a
.lpTemplateName
!= NULL
)
464 HeapFree(GetProcessHeap(), 0, (LPSTR
)(cf_a
.lpTemplateName
));
468 ChooseFontAtoW(&cf_a
, lpChFont
);
474 /***********************************************************************
475 * ChooseFontW (COMDLG32.@)
477 BOOL WINAPI
ChooseFontW(LPCHOOSEFONTW lpChFont
)
483 HANDLE hResInfo
, hDlgTmpl
;
485 if (TRACE_ON(commdlg
))
486 _dump_cf_flags(lpChFont
->Flags
);
488 if (!(hResInfo
= FindResourceA(COMDLG32_hInstance
, "CHOOSE_FONT", RT_DIALOGA
)))
490 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
493 if (!(hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
)) ||
494 !(template = LockResource( hDlgTmpl
)))
496 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
500 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
501 CF_ENABLETEMPLATEHANDLE
)) FIXME(": unimplemented flag (ignored)\n");
502 memcpy(&cf32a
, lpChFont
, sizeof(cf32a
));
503 memcpy(&lf32a
, lpChFont
->lpLogFont
, sizeof(LOGFONTA
));
505 WideCharToMultiByte( CP_ACP
, 0, lpChFont
->lpLogFont
->lfFaceName
, -1,
506 lf32a
.lfFaceName
, LF_FACESIZE
, NULL
, NULL
);
507 lf32a
.lfFaceName
[LF_FACESIZE
-1] = 0;
508 cf32a
.lpLogFont
=&lf32a
;
509 cf32a
.lpszStyle
=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont
->lpszStyle
);
510 lpChFont
->lpTemplateName
=(LPWSTR
)&cf32a
;
511 bRet
= DialogBoxIndirectParamW(COMDLG32_hInstance
, template,
512 lpChFont
->hwndOwner
, FormatCharDlgProcW
, (LPARAM
)lpChFont
);
513 HeapFree(GetProcessHeap(), 0, cf32a
.lpszStyle
);
514 lpChFont
->lpTemplateName
=(LPWSTR
)cf32a
.lpTemplateName
;
515 memcpy(lpChFont
->lpLogFont
, &lf32a
, sizeof(CHOOSEFONTA
));
516 MultiByteToWideChar( CP_ACP
, 0, lf32a
.lfFaceName
, -1,
517 lpChFont
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
518 lpChFont
->lpLogFont
->lfFaceName
[LF_FACESIZE
-1] = 0;
523 #define TEXT_EXTRAS 4
524 #define TEXT_COLORS 16
526 static const COLORREF textcolors
[TEXT_COLORS
]=
528 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
529 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
530 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
531 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
534 /***********************************************************************
535 * CFn_HookCallChk [internal]
537 static BOOL
CFn_HookCallChk(LPCHOOSEFONT16 lpcf
)
540 if(lpcf
->Flags
& CF_ENABLEHOOK
)
546 /***********************************************************************
547 * CFn_HookCallChk32 [internal]
549 static BOOL
CFn_HookCallChk32(LPCHOOSEFONTA lpcf
)
552 if(lpcf
->Flags
& CF_ENABLEHOOK
)
562 LPCHOOSEFONTA lpcf32a
;
564 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
566 /*************************************************************************
567 * AddFontFamily [internal]
569 static INT
AddFontFamily(const LOGFONTA
*lplf
, UINT nFontType
,
570 LPCHOOSEFONTA lpcf
, HWND hwnd
, LPCFn_ENUMSTRUCT e
)
575 TRACE("font=%s (nFontType=%d)\n", lplf
->lfFaceName
,nFontType
);
577 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
578 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
580 if (lpcf
->Flags
& CF_ANSIONLY
)
581 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
583 if (lpcf
->Flags
& CF_TTONLY
)
584 if (!(nFontType
& TRUETYPE_FONTTYPE
))
589 i
=SendMessageA(hwnd
, CB_ADDSTRING
, 0, (LPARAM
)lplf
->lfFaceName
);
592 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
593 SendMessageA(hwnd
, CB_SETITEMDATA
, i
, MAKELONG(nFontType
,w
));
594 return 1 ; /* store some important font information */
600 /*************************************************************************
601 * FontFamilyEnumProc32 [internal]
603 static INT WINAPI
FontFamilyEnumProc(const LOGFONTA
*lpLogFont
,
604 const TEXTMETRICA
*metrics
, DWORD dwFontType
, LPARAM lParam
)
607 e
=(LPCFn_ENUMSTRUCT
)lParam
;
608 return AddFontFamily(lpLogFont
, dwFontType
, e
->lpcf32a
, e
->hWnd1
, e
);
611 /***********************************************************************
612 * FontFamilyEnumProc (COMMDLG.19)
614 INT16 WINAPI
FontFamilyEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
615 UINT16 nFontType
, LPARAM lParam
)
617 HWND hwnd
=HWND_32(LOWORD(lParam
));
618 HWND hDlg
=GetParent(hwnd
);
619 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLongA(hDlg
, DWL_USER
);
620 LOGFONT16
*lplf
= MapSL( logfont
);
622 FONT_LogFont16To32A(lplf
, &lf32a
);
623 return AddFontFamily(&lf32a
, nFontType
, (LPCHOOSEFONTA
)lpcf
->lpTemplateName
,
627 /*************************************************************************
628 * SetFontStylesToCombo2 [internal]
630 * Fill font style information into combobox (without using font.c directly)
632 static int SetFontStylesToCombo2(HWND hwnd
, HDC hdc
, const LOGFONTA
*lplf
)
639 static struct FONTSTYLE fontstyles
[FSTYLES
]={
640 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
641 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
647 memcpy(&lf
, lplf
, sizeof(LOGFONTA
));
649 for (i
=0;i
<FSTYLES
;i
++)
651 lf
.lfItalic
=fontstyles
[i
].italic
;
652 lf
.lfWeight
=fontstyles
[i
].weight
;
653 hf
=CreateFontIndirectA(&lf
);
654 hf
=SelectObject(hdc
,hf
);
655 GetTextMetricsA(hdc
,&tm
);
656 hf
=SelectObject(hdc
,hf
);
659 if (tm
.tmWeight
==fontstyles
[i
].weight
&&
660 tm
.tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
662 j
=SendMessageA(hwnd
,CB_ADDSTRING
,0,(LPARAM
)fontstyles
[i
].stname
);
663 if (j
==CB_ERR
) return 1;
664 j
=SendMessageA(hwnd
, CB_SETITEMDATA
, j
,
665 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
666 if (j
==CB_ERR
) return 1;
672 /*************************************************************************
673 * AddFontSizeToCombo3 [internal]
675 static int AddFontSizeToCombo3(HWND hwnd
, UINT h
, LPCHOOSEFONTA lpcf
)
680 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
681 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
683 sprintf(buffer
, "%2d", h
);
684 j
=SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buffer
);
687 j
=SendMessageA(hwnd
, CB_ADDSTRING
, 0, (LPARAM
)buffer
);
688 if (j
!=CB_ERR
) j
= SendMessageA(hwnd
, CB_SETITEMDATA
, j
, h
);
689 if (j
==CB_ERR
) return 1;
695 /*************************************************************************
696 * SetFontSizesToCombo3 [internal]
698 static int SetFontSizesToCombo3(HWND hwnd
, LPCHOOSEFONTA lpcf
)
700 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
703 for (i
=0; sizes
[i
]; i
++)
704 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
708 /***********************************************************************
709 * AddFontStyle [internal]
711 static INT
AddFontStyle(const LOGFONTA
*lplf
, UINT nFontType
,
712 LPCHOOSEFONTA lpcf
, HWND hcmb2
, HWND hcmb3
, HWND hDlg
)
716 TRACE("(nFontType=%d)\n",nFontType
);
717 TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
718 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
719 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,
720 lplf
->lfEscapement
,lplf
->lfOrientation
,
721 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
722 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
723 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
724 if (nFontType
& RASTER_FONTTYPE
)
726 if (AddFontSizeToCombo3(hcmb3
, lplf
->lfHeight
, lpcf
)) return 0;
727 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
729 if (!SendMessageA(hcmb2
, CB_GETCOUNT
, 0, 0))
731 HDC hdc
= ((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
) ? lpcf
->hDC
: GetDC(hDlg
);
732 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
733 if (!((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
))
742 /***********************************************************************
743 * FontStyleEnumProc (COMMDLG.18)
745 INT16 WINAPI
FontStyleEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
746 UINT16 nFontType
, LPARAM lParam
)
748 HWND hcmb2
=HWND_32(LOWORD(lParam
));
749 HWND hcmb3
=HWND_32(HIWORD(lParam
));
750 HWND hDlg
=GetParent(hcmb3
);
751 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLongA(hDlg
, DWL_USER
);
752 LOGFONT16
*lplf
= MapSL(logfont
);
754 FONT_LogFont16To32A(lplf
, &lf32a
);
755 return AddFontStyle(&lf32a
, nFontType
, (LPCHOOSEFONTA
)lpcf
->lpTemplateName
,
759 /***********************************************************************
760 * FontStyleEnumProc32 [internal]
762 static INT WINAPI
FontStyleEnumProc( const LOGFONTA
*lpFont
,
763 const TEXTMETRICA
*metrics
, DWORD dwFontType
, LPARAM lParam
)
765 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
768 HWND hDlg
=GetParent(hcmb3
);
769 return AddFontStyle(lpFont
, dwFontType
, s
->lpcf32a
, hcmb2
,
773 /***********************************************************************
774 * CFn_WMInitDialog [internal]
776 static LRESULT
CFn_WMInitDialog(HWND hDlg
, WPARAM wParam
, LPARAM lParam
,
783 HCURSOR hcursor
=SetCursor(LoadCursorA(0,IDC_WAITA
));
785 SetWindowLongA(hDlg
, DWL_USER
, lParam
);
786 lpxx
=lpcf
->lpLogFont
;
787 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
789 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONTA
))
791 ERR("structure size failure !!!\n");
796 hBitmapTT
= LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE
));
798 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow(lpcf
->hwndOwner
))
799 ShowWindow(GetDlgItem(hDlg
,pshHelp
),SW_HIDE
);
800 if (!(lpcf
->Flags
& CF_APPLY
))
801 ShowWindow(GetDlgItem(hDlg
,psh3
),SW_HIDE
);
802 if (lpcf
->Flags
& CF_EFFECTS
)
804 for (i
=0;i
<TEXT_COLORS
;i
++)
808 if( LoadStringA(COMDLG32_hInstance
, IDS_COLOR_BLACK
+i
, name
,
809 sizeof(name
)/sizeof(*name
) )==0 )
811 strcpy( name
, "[color name]" );
813 j
=SendDlgItemMessageA(hDlg
, cmb4
, CB_ADDSTRING
, 0, (LPARAM
)name
);
814 SendDlgItemMessageA(hDlg
, cmb4
, CB_SETITEMDATA16
, j
, textcolors
[j
]);
815 /* look for a fitting value in color combobox */
816 if (textcolors
[j
]==lpcf
->rgbColors
)
817 SendDlgItemMessageA(hDlg
,cmb4
, CB_SETCURSEL
,j
,0);
822 ShowWindow(GetDlgItem(hDlg
,cmb4
),SW_HIDE
);
823 ShowWindow(GetDlgItem(hDlg
,chx1
),SW_HIDE
);
824 ShowWindow(GetDlgItem(hDlg
,chx2
),SW_HIDE
);
825 ShowWindow(GetDlgItem(hDlg
,grp1
),SW_HIDE
);
826 ShowWindow(GetDlgItem(hDlg
,stc4
),SW_HIDE
);
828 hdc
= ((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
) ? lpcf
->hDC
: GetDC(hDlg
);
832 s
.hWnd1
=GetDlgItem(hDlg
,cmb1
);
836 if (!EnumFontFamiliesA(hdc
, NULL
, FontFamilyEnumProc
, (LPARAM
)&s
)) {
837 TRACE("EnumFontFamilies returns 0\n");
841 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
) {
842 FIXME("No founds found with fixed pitch only, dropping flag.\n");
843 lpcf
->Flags
&= ~CF_FIXEDPITCHONLY
;
846 if (lpcf
->Flags
& CF_TTONLY
) {
847 FIXME("No founds found with truetype only, dropping flag.\n");
848 lpcf
->Flags
&= ~CF_TTONLY
;
855 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
857 /* look for fitting font name in combobox1 */
858 j
=SendDlgItemMessageA(hDlg
,cmb1
,CB_FINDSTRING
,-1,(LONG
)lpxx
->lfFaceName
);
861 SendDlgItemMessageA(hDlg
, cmb1
, CB_SETCURSEL
, j
, 0);
862 SendMessageA(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
863 (LPARAM
)GetDlgItem(hDlg
,cmb1
));
865 /* look for fitting font style in combobox2 */
866 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
867 for (i
=0;i
<TEXT_EXTRAS
;i
++)
869 if (l
==SendDlgItemMessageA(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0))
870 SendDlgItemMessageA(hDlg
, cmb2
, CB_SETCURSEL
, i
, 0);
873 /* look for fitting font size in combobox3 */
874 j
=SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCOUNT
, 0, 0);
877 if (lpxx
->lfHeight
==(int)SendDlgItemMessageA(hDlg
,cmb3
, CB_GETITEMDATA
,i
,0))
878 SendDlgItemMessageA(hDlg
,cmb3
,CB_SETCURSEL
,i
,0);
884 SendDlgItemMessageA(hDlg
,cmb1
,CB_SETCURSEL
,0,0);
885 SendMessageA(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
886 (LPARAM
)GetDlgItem(hDlg
,cmb1
));
888 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
890 j
=SendDlgItemMessageA(hDlg
,cmb2
,CB_FINDSTRING
,-1,(LONG
)lpcf
->lpszStyle
);
893 j
=SendDlgItemMessageA(hDlg
,cmb2
,CB_SETCURSEL
,j
,0);
894 SendMessageA(hDlg
,WM_COMMAND
,cmb2
,
895 MAKELONG(HWND_16(GetDlgItem(hDlg
,cmb2
)),CBN_SELCHANGE
));
901 WARN("HDC failure !!!\n");
906 if (!((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
))
913 /***********************************************************************
914 * CFn_WMMeasureItem [internal]
916 static LRESULT
CFn_WMMeasureItem(HWND hDlg
, WPARAM wParam
, LPARAM lParam
)
919 LPMEASUREITEMSTRUCT lpmi
=(LPMEASUREITEMSTRUCT
)lParam
;
921 hBitmapTT
= LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE
));
922 GetObjectA( hBitmapTT
, sizeof(bm
), &bm
);
923 lpmi
->itemHeight
=bm
.bmHeight
;
924 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
929 /***********************************************************************
930 * CFn_WMDrawItem [internal]
932 static LRESULT
CFn_WMDrawItem(HWND hDlg
, WPARAM wParam
, LPARAM lParam
)
937 COLORREF cr
, oldText
=0, oldBk
=0;
942 HBITMAP hBitmap
; /* for later TT usage */
944 LPDRAWITEMSTRUCT lpdi
= (LPDRAWITEMSTRUCT
)lParam
;
946 if (lpdi
->itemID
== (UINT
)-1) /* got no items */
947 DrawFocusRect(lpdi
->hDC
, &lpdi
->rcItem
);
950 if (lpdi
->CtlType
== ODT_COMBOBOX
)
952 if (lpdi
->itemState
==ODS_SELECTED
)
954 hBrush
=GetSysColorBrush(COLOR_HIGHLIGHT
);
955 oldText
=SetTextColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHTTEXT
));
956 oldBk
=SetBkColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHT
));
959 hBrush
= SelectObject(lpdi
->hDC
, GetStockObject(LTGRAY_BRUSH
));
960 SelectObject(lpdi
->hDC
, hBrush
);
962 FillRect(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
965 return TRUE
; /* this should never happen */
970 case cmb1
: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
971 SendMessageA(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
973 GetObjectA( hBitmapTT
, sizeof(bm
), &bm
);
974 TextOutA(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
975 lpdi
->rcItem
.top
, buffer
, strlen(buffer
));
977 nFontType
= SendMessageA(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
978 /* FIXME: draw bitmap if truetype usage */
979 if (nFontType
&TRUETYPE_FONTTYPE
)
981 hMemDC
= CreateCompatibleDC(lpdi
->hDC
);
982 hBitmap
= SelectObject(hMemDC
, hBitmapTT
);
983 BitBlt(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
984 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
985 SelectObject(hMemDC
, hBitmap
);
991 case cmb3
: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
992 SendMessageA(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
994 TextOutA(lpdi
->hDC
, lpdi
->rcItem
.left
,
995 lpdi
->rcItem
.top
, buffer
, strlen(buffer
));
998 case cmb4
: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
999 SendMessageA(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
1001 TextOutA(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
1002 lpdi
->rcItem
.top
, buffer
, strlen(buffer
));
1003 cr
= SendMessageA(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
1004 hBrush
= CreateSolidBrush(cr
);
1007 hBrush
= SelectObject (lpdi
->hDC
, hBrush
) ;
1008 rect
.right
=rect
.left
+25;
1012 Rectangle( lpdi
->hDC
, rect
.left
, rect
.top
,
1013 rect
.right
, rect
.bottom
);
1014 DeleteObject( SelectObject (lpdi
->hDC
, hBrush
)) ;
1020 default: return TRUE
; /* this should never happen */
1022 if (lpdi
->itemState
== ODS_SELECTED
)
1024 SetTextColor(lpdi
->hDC
, oldText
);
1025 SetBkColor(lpdi
->hDC
, oldBk
);
1031 /***********************************************************************
1032 * CFn_WMCommand [internal]
1034 static LRESULT
CFn_WMCommand(HWND hDlg
, WPARAM wParam
, LPARAM lParam
,
1040 LPLOGFONTA lpxx
=lpcf
->lpLogFont
;
1042 TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG
)wParam
, lParam
);
1043 switch (LOWORD(wParam
))
1045 case cmb1
:if (HIWORD(wParam
)==CBN_SELCHANGE
)
1047 hdc
=((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
) ? lpcf
->hDC
: GetDC(hDlg
);
1050 SendDlgItemMessageA(hDlg
, cmb2
, CB_RESETCONTENT16
, 0, 0);
1051 SendDlgItemMessageA(hDlg
, cmb3
, CB_RESETCONTENT16
, 0, 0);
1052 i
=SendDlgItemMessageA(hDlg
, cmb1
, CB_GETCURSEL16
, 0, 0);
1055 HCURSOR hcursor
=SetCursor(LoadCursorA(0,IDC_WAITA
));
1058 SendDlgItemMessageA(hDlg
, cmb1
, CB_GETLBTEXT
, i
,
1060 TRACE("WM_COMMAND/cmb1 =>%s\n",str
);
1061 s
.hWnd1
=GetDlgItem(hDlg
, cmb2
);
1062 s
.hWnd2
=GetDlgItem(hDlg
, cmb3
);
1064 EnumFontFamiliesA(hdc
, str
, FontStyleEnumProc
, (LPARAM
)&s
);
1065 SendDlgItemMessageA(hDlg
,cmb2
, CB_SETCURSEL
, 0, 0);
1066 SendDlgItemMessageA(hDlg
,cmb3
, CB_SETCURSEL
, 0, 0);
1069 if (!((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
))
1070 ReleaseDC(hDlg
,hdc
);
1074 WARN("HDC failure !!!\n");
1075 EndDialog (hDlg
, 0);
1082 case cmb3
:if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
1087 TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
1088 i
=SendDlgItemMessageA(hDlg
,cmb1
,CB_GETCURSEL
,0,0);
1090 i
=GetDlgItemTextA( hDlg
, cmb1
, str
, 256 );
1093 SendDlgItemMessageA(hDlg
,cmb1
,CB_GETLBTEXT
,i
,
1095 l
=SendDlgItemMessageA(hDlg
,cmb1
,CB_GETITEMDATA
,i
,0);
1097 lpcf
->nFontType
= LOWORD(l
);
1098 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
1099 /* same value reported to the EnumFonts
1100 call back with the extra FONTTYPE_... bits added */
1101 lpxx
->lfPitchAndFamily
=j
&0xff;
1102 lpxx
->lfCharSet
=j
>>8;
1104 strcpy(lpxx
->lfFaceName
,str
);
1105 i
=SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1108 l
=SendDlgItemMessageA(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0);
1109 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
1110 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
1111 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
1112 lpcf
->nFontType
|= BOLD_FONTTYPE
;
1114 i
=SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1116 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessageA(hDlg
, cmb3
, CB_GETITEMDATA
, i
, 0));
1119 lpxx
->lfStrikeOut
=IsDlgButtonChecked(hDlg
,chx1
);
1120 lpxx
->lfUnderline
=IsDlgButtonChecked(hDlg
,chx2
);
1121 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
1122 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
1123 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
1124 lpxx
->lfQuality
=DEFAULT_QUALITY
;
1125 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
1127 wininfo
.cbSize
=sizeof(wininfo
);
1129 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1131 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1137 i
=SendDlgItemMessageA(hDlg
, cmb4
, CB_GETCURSEL
, 0, 0);
1142 lpcf
->rgbColors
=textcolors
[i
];
1143 wininfo
.cbSize
=sizeof(wininfo
);
1145 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1147 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1152 case psh15
:i
=RegisterWindowMessageA( HELPMSGSTRINGA
);
1153 if (lpcf
->hwndOwner
)
1154 SendMessageA(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetWindowLongA(hDlg
, DWL_USER
));
1155 /* if (CFn_HookCallChk(lpcf))
1156 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
1159 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
1160 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
1161 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
1162 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
1163 EndDialog(hDlg
, TRUE
);
1167 sprintf(buffer
,"Select a font size between %d and %d points.",
1168 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
1169 MessageBoxA(hDlg
, buffer
, NULL
, MB_OK
);
1172 case IDCANCEL
:EndDialog(hDlg
, FALSE
);
1178 static LRESULT
CFn_WMDestroy(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1183 static LRESULT
CFn_WMPaint(HWND hDlg
, WPARAM wParam
, LPARAM lParam
,
1184 LPCHOOSEFONTA lpcf
)
1188 info
.cbSize
=sizeof(info
);
1190 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &info
) )
1197 WCHAR sample
[SAMPLE_EXTLEN
+5]={'A','a','B','b'};
1198 /* Always start with this basic sample */
1200 hdc
=BeginPaint( hDlg
, &ps
);
1203 MoveToEx( hdc
, info
.rcWindow
.left
, info
.rcWindow
.bottom
, NULL
);
1204 hOrigPen
=SelectObject( hdc
, CreatePen( PS_SOLID
, 2,
1205 GetSysColor( COLOR_3DSHADOW
) ));
1206 LineTo( hdc
, info
.rcWindow
.left
, info
.rcWindow
.top
);
1207 LineTo( hdc
, info
.rcWindow
.right
, info
.rcWindow
.top
);
1208 DeleteObject(SelectObject( hdc
, CreatePen( PS_SOLID
, 2,
1209 GetSysColor( COLOR_3DLIGHT
) )));
1210 LineTo( hdc
, info
.rcWindow
.right
, info
.rcWindow
.bottom
);
1211 LineTo( hdc
, info
.rcWindow
.left
, info
.rcWindow
.bottom
);
1212 DeleteObject(SelectObject( hdc
, hOrigPen
));
1214 /* Draw the sample text itself */
1215 lstrcatW(sample
, SAMPLE_LANG_TEXT
[CHARSET_ORDER
[lpcf
->lpLogFont
->lfCharSet
]] );
1217 info
.rcWindow
.right
--;
1218 info
.rcWindow
.bottom
--;
1219 info
.rcWindow
.top
++;
1220 info
.rcWindow
.left
++;
1221 hOrigFont
=SelectObject( hdc
, CreateFontIndirectA( lpcf
->lpLogFont
) );
1222 rgbPrev
=SetTextColor( hdc
, lpcf
->rgbColors
);
1224 DrawTextW( hdc
, sample
, -1, &info
.rcWindow
, DT_CENTER
|DT_VCENTER
|DT_SINGLELINE
);
1226 EndPaint( hDlg
, &ps
);
1232 /***********************************************************************
1233 * FormatCharDlgProc (COMMDLG.16)
1234 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
1235 2. some CF_.. flags are not supported
1236 3. some TType extensions
1238 BOOL16 CALLBACK
FormatCharDlgProc16(HWND16 hDlg16
, UINT16 message
,
1239 WPARAM16 wParam
, LPARAM lParam
)
1241 HWND hDlg
= HWND_32(hDlg16
);
1242 LPCHOOSEFONT16 lpcf
;
1243 LPCHOOSEFONTA lpcf32a
;
1245 if (message
!=WM_INITDIALOG
)
1247 lpcf
=(LPCHOOSEFONT16
)GetWindowLongA(hDlg
, DWL_USER
);
1250 if (CFn_HookCallChk(lpcf
))
1251 res
=CallWindowProc16((WNDPROC16
)lpcf
->lpfnHook
,hDlg16
,message
,wParam
,lParam
);
1257 lpcf
=(LPCHOOSEFONT16
)lParam
;
1258 lpcf32a
=(LPCHOOSEFONTA
)lpcf
->lpTemplateName
;
1259 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
1261 TRACE("CFn_WMInitDialog returned FALSE\n");
1264 if (CFn_HookCallChk(lpcf
))
1265 return CallWindowProc16((WNDPROC16
)lpcf
->lpfnHook
,hDlg16
,WM_INITDIALOG
,wParam
,lParam
);
1267 lpcf32a
=(LPCHOOSEFONTA
)lpcf
->lpTemplateName
;
1270 case WM_MEASUREITEM
:
1272 MEASUREITEMSTRUCT16
* mis16
= MapSL(lParam
);
1273 MEASUREITEMSTRUCT mis
;
1274 mis
.CtlType
= mis16
->CtlType
;
1275 mis
.CtlID
= mis16
->CtlID
;
1276 mis
.itemID
= mis16
->itemID
;
1277 mis
.itemWidth
= mis16
->itemWidth
;
1278 mis
.itemHeight
= mis16
->itemHeight
;
1279 mis
.itemData
= mis16
->itemData
;
1280 res
= CFn_WMMeasureItem(hDlg
, wParam
, (LPARAM
)&mis
);
1281 mis16
->itemWidth
= (UINT16
)mis
.itemWidth
;
1282 mis16
->itemHeight
= (UINT16
)mis
.itemHeight
;
1287 DRAWITEMSTRUCT16
* dis16
= MapSL(lParam
);
1289 dis
.CtlType
= dis16
->CtlType
;
1290 dis
.CtlID
= dis16
->CtlID
;
1291 dis
.itemID
= dis16
->itemID
;
1292 dis
.itemAction
= dis16
->itemAction
;
1293 dis
.itemState
= dis16
->itemState
;
1294 dis
.hwndItem
= HWND_32(dis16
->hwndItem
);
1295 dis
.hDC
= HDC_32(dis16
->hDC
);
1296 dis
.itemData
= dis16
->itemData
;
1297 CONV_RECT16TO32( &dis16
->rcItem
, &dis
.rcItem
);
1298 res
= CFn_WMDrawItem(hDlg
, wParam
, (LPARAM
)&dis
);
1302 res
=CFn_WMCommand(hDlg
, MAKEWPARAM( wParam
, HIWORD(lParam
) ), LOWORD(lParam
), lpcf32a
);
1305 res
=CFn_WMDestroy(hDlg
, wParam
, lParam
);
1307 case WM_CHOOSEFONT_GETLOGFONT
:
1308 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam
);
1309 FIXME("current logfont back to caller\n");
1315 /***********************************************************************
1316 * FormatCharDlgProcA [internal]
1318 INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1322 INT_PTR res
= FALSE
;
1323 if (uMsg
!=WM_INITDIALOG
)
1325 lpcf
=(LPCHOOSEFONTA
)GetWindowLongA(hDlg
, DWL_USER
);
1328 if (CFn_HookCallChk32(lpcf
))
1329 res
=CallWindowProcA((WNDPROC
)lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1335 lpcf
=(LPCHOOSEFONTA
)lParam
;
1336 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf
))
1338 TRACE("CFn_WMInitDialog returned FALSE\n");
1341 if (CFn_HookCallChk32(lpcf
))
1342 return CallWindowProcA((WNDPROC
)lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1346 case WM_MEASUREITEM
:
1347 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
1349 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
1351 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
1353 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
1354 case WM_CHOOSEFONT_GETLOGFONT
:
1355 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1357 FIXME("current logfont back to caller\n");
1360 return CFn_WMPaint(hDlg
, wParam
, lParam
, lpcf
);
1365 /***********************************************************************
1366 * FormatCharDlgProcW [internal]
1368 INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1371 LPCHOOSEFONTW lpcf32w
;
1372 LPCHOOSEFONTA lpcf32a
;
1373 INT_PTR res
= FALSE
;
1374 if (uMsg
!=WM_INITDIALOG
)
1376 lpcf32w
=(LPCHOOSEFONTW
)GetWindowLongA(hDlg
, DWL_USER
);
1379 if (CFn_HookCallChk32((LPCHOOSEFONTA
)lpcf32w
))
1380 res
=CallWindowProcW((WNDPROC
)lpcf32w
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1386 lpcf32w
=(LPCHOOSEFONTW
)lParam
;
1387 lpcf32a
=(LPCHOOSEFONTA
)lpcf32w
->lpTemplateName
;
1388 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
1390 TRACE("CFn_WMInitDialog returned FALSE\n");
1393 if (CFn_HookCallChk32((LPCHOOSEFONTA
)lpcf32w
))
1394 return CallWindowProcW((WNDPROC
)lpcf32w
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1396 lpcf32a
=(LPCHOOSEFONTA
)lpcf32w
->lpTemplateName
;
1399 case WM_MEASUREITEM
:
1400 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
1402 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
1404 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf32a
);
1406 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
1407 case WM_CHOOSEFONT_GETLOGFONT
:
1408 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1410 FIXME("current logfont back to caller\n");