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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
35 #include "wine/heap.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
45 LPCHOOSEFONTW lpcf32w
;
47 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
50 static const WCHAR strWineFontData
[] = L
"__WINE_FONTDLGDATA";
51 static const WCHAR strWineFontData_a
[] = L
"__WINE_FONTDLGDATA_A";
53 /* image list with TrueType bitmaps and more */
54 static HIMAGELIST himlTT
= 0;
55 #define TTBITMAP_XSIZE 20 /* x-size of the bitmaps */
57 static INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
58 static INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
60 /* There is a table here of all charsets, and the sample text for each.
61 * There is a second table that translates a charset into an index into
65 #define CI(cs) ((IDS_CHARSET_##cs)-IDS_CHARSET_ANSI)
67 static const WCHAR
* const sample_lang_text
[]={
68 L
"AaBbYyZz", /* Western and default */
69 L
"Symbol", /* Symbol */
70 L
"Aa\x3042\x3041\x30a2\x30a1\x4e9c\x5b87", /* Shift JIS */
71 L
"\xac00\xb098\xb2e4" "AaBYyZz", /* Hangul */
72 L
"\x5fae\x8f6f\x4e2d\x6587\x8f6f\x4ef6", /* GB2312 */
73 L
"\x4e2d\x6587\x5b57\x578b\x7bc4\x4f8b", /* BIG5 */
74 L
"AaBb\x0391\x03b1\x0392\x03b2", /* Greek */
75 L
"AaBb\x011e\x011f\x015e\x015f", /* Turkish */
76 L
"AaBb\x05e0\x05e1\x05e9\x05ea", /* Hebrew */
77 L
"AaBb\x0627\x0628\x062c\x062f\x0647\x0648\x0632", /* Arabic */
78 L
"AaBbYyZz", /* Baltic */
79 L
"AaBb\x01a0\x01a1\x01af\x01b0", /* Vietnamese */
80 L
"AaBb\x0411\x0431\x0424\x0444", /* Cyrillic */
81 L
"AaBb\x00c1\x00e1\x00d4\x00f4", /* East European */
82 L
"AaBb\x0e2d\x0e31\x0e01\x0e29\x0e23\x0e44\x0e17\x0e22", /* Thai */
83 L
"\xac00\xb098\xb2e4" "AaBYyZz", /* Johab */
84 L
"AaBbYyZz", /* Mac */
85 L
"AaBb\x00f8\x00f1\x00fd", /* OEM */
86 /* the following character sets actually behave different (Win2K observation):
87 * the sample string is 'sticky': it uses the sample string of the previous
88 * selected character set. That behaviour looks like some default, which is
89 * not (yet) implemented. */
93 L
"AaBb", /* ISO-8859-3 */
94 L
"AaBb", /* ISO-8859-4 */
95 L
"AaBb", /* ISO-8859-10 */
100 static const BYTE CHARSET_ORDER
[256]={
101 CI(ANSI
), 0, CI(SYMBOL
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(MAC
), 0, 0,
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
107 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109 CI(JIS
), CI(HANGUL
), CI(JOHAB
), 0, 0, 0, CI(GB2312
), 0, CI(BIG5
), 0, 0, 0, 0, 0, 0, 0,
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, CI(GREEK
), CI(TURKISH
), CI(VIETNAMESE
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, CI(HEBREW
), CI(ARABIC
), 0, 0, 0, 0, 0, 0, 0, CI(BALTIC
), 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(RUSSIAN
), 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(THAI
), 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(EE
), 0,
116 CI(VISCII
), CI(TCVN
), CI(KOI8
), CI(ISO3
), CI(ISO4
), CI(ISO10
), CI(CELTIC
), 0, 0, 0, 0, 0, 0, 0, 0, CI(OEM
),
119 static const struct {
123 #define XX(x) { x, #x },
128 XX(CF_ENABLETEMPLATE
)
129 XX(CF_ENABLETEMPLATEHANDLE
)
130 XX(CF_INITTOLOGFONTSTRUCT
)
138 XX(CF_FIXEDPITCHONLY
)
140 XX(CF_FORCEFONTEXIST
)
152 static void _dump_cf_flags(DWORD cflags
)
156 for (i
= 0; i
< ARRAY_SIZE(cfflags
); i
++)
157 if (cfflags
[i
].mask
& cflags
)
158 TRACE("%s|",cfflags
[i
].name
);
162 /***********************************************************************
163 * ChooseFontW (COMDLG32.@)
165 * Create a font dialog box.
168 * lpChFont [I/O] in: information to initialize the dialog box.
169 * out: User's color selection
172 * TRUE: Ok button clicked.
173 * FALSE: Cancel button clicked, or error.
175 BOOL WINAPI
ChooseFontW(LPCHOOSEFONTW lpChFont
)
182 TRACE("(%p)\n", lpChFont
);
184 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATEHANDLE
)!=0 )
186 template=lpChFont
->hInstance
;
189 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATE
)!=0 )
191 hDlginst
=lpChFont
->hInstance
;
192 if( !(hResInfo
= FindResourceW(hDlginst
, lpChFont
->lpTemplateName
,
195 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
200 hDlginst
=COMDLG32_hInstance
;
201 if (!(hResInfo
= FindResourceW(hDlginst
, L
"CHOOSE_FONT", (LPWSTR
)RT_DIALOG
)))
203 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
207 if (!(hDlgTmpl
= LoadResource(hDlginst
, hResInfo
)) ||
208 !(template = LockResource( hDlgTmpl
)))
210 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
214 if (TRACE_ON(commdlg
))
215 _dump_cf_flags(lpChFont
->Flags
);
217 if (lpChFont
->Flags
& CF_SELECTSCRIPT
)
218 FIXME(": unimplemented flag (ignored)\n");
220 return DialogBoxIndirectParamW(COMDLG32_hInstance
, template,
221 lpChFont
->hwndOwner
, FormatCharDlgProcW
, (LPARAM
)lpChFont
);
224 /***********************************************************************
225 * ChooseFontA (COMDLG32.@)
229 BOOL WINAPI
ChooseFontA(LPCHOOSEFONTA lpChFont
)
236 TRACE("(%p)\n", lpChFont
);
238 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATEHANDLE
)!=0 )
240 template=lpChFont
->hInstance
;
243 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATE
)!=0 )
245 hDlginst
=lpChFont
->hInstance
;
246 if( !(hResInfo
= FindResourceA(hDlginst
, lpChFont
->lpTemplateName
,
249 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
254 hDlginst
=COMDLG32_hInstance
;
255 if (!(hResInfo
= FindResourceW(hDlginst
, L
"CHOOSE_FONT", (LPWSTR
)RT_DIALOG
)))
257 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
261 if (!(hDlgTmpl
= LoadResource(hDlginst
, hResInfo
)) ||
262 !(template = LockResource( hDlgTmpl
)))
264 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
268 if (TRACE_ON(commdlg
))
269 _dump_cf_flags(lpChFont
->Flags
);
270 if (lpChFont
->Flags
& CF_SELECTSCRIPT
)
271 FIXME(": unimplemented flag (ignored)\n");
273 return DialogBoxIndirectParamA(COMDLG32_hInstance
, template,
274 lpChFont
->hwndOwner
, FormatCharDlgProcA
, (LPARAM
)lpChFont
);
277 #define TEXT_EXTRAS 4
278 #define TEXT_COLORS 16
280 static const COLORREF textcolors
[TEXT_COLORS
]=
282 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
283 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
284 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
285 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
288 /***********************************************************************
289 * CFn_HookCallChk32 [internal]
291 static BOOL
CFn_HookCallChk32(const CHOOSEFONTW
*lpcf
)
294 if(lpcf
->Flags
& CF_ENABLEHOOK
)
300 /*************************************************************************
301 * AddFontFamily [internal]
303 static INT
AddFontFamily(const ENUMLOGFONTEXW
*lpElfex
, const NEWTEXTMETRICEXW
*lpNTM
,
304 UINT nFontType
, const CHOOSEFONTW
*lpcf
, HWND hwnd
, LPCFn_ENUMSTRUCT e
)
308 const LOGFONTW
*lplf
= &(lpElfex
->elfLogFont
);
310 TRACE("font=%s (nFontType=%d)\n", debugstr_w(lplf
->lfFaceName
), nFontType
);
312 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
313 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
315 if (lpcf
->Flags
& CF_ANSIONLY
)
316 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
318 if (lpcf
->Flags
& CF_TTONLY
)
319 if (!(nFontType
& TRUETYPE_FONTTYPE
))
321 if (lpcf
->Flags
& CF_NOVERTFONTS
)
322 if (lplf
->lfFaceName
[0] == '@')
327 i
=SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)lplf
->lfFaceName
);
329 i
= SendMessageW(hwnd
, CB_ADDSTRING
, 0, (LPARAM
)lplf
->lfFaceName
);
331 /* store some important font information */
332 w
= (lplf
->lfPitchAndFamily
) << 8 |
333 (HIWORD(lpNTM
->ntmTm
.ntmFlags
) & 0xff);
334 SendMessageW(hwnd
, CB_SETITEMDATA
, i
, MAKELONG(nFontType
,w
));
340 /*************************************************************************
341 * FontFamilyEnumProc32 [internal]
343 static INT WINAPI
FontFamilyEnumProc(const ENUMLOGFONTEXW
*lpElfex
,
344 const TEXTMETRICW
*metrics
, DWORD dwFontType
, LPARAM lParam
)
347 e
=(LPCFn_ENUMSTRUCT
)lParam
;
348 return AddFontFamily( lpElfex
, (const NEWTEXTMETRICEXW
*) metrics
,
349 dwFontType
, e
->lpcf32w
, e
->hWnd1
, e
);
352 /*************************************************************************
353 * SetFontStylesToCombo2 [internal]
355 * Fill font style information into combobox (without using font.c directly)
357 static BOOL
SetFontStylesToCombo2(HWND hwnd
, HDC hdc
, const LOGFONTW
*lplf
)
366 static const struct FONTSTYLE fontstyles
[FSTYLES
]={
367 { 0, FW_NORMAL
, IDS_FONT_REGULAR
},
368 { 1, FW_NORMAL
, IDS_FONT_ITALIC
},
369 { 0, FW_BOLD
, IDS_FONT_BOLD
},
370 { 1, FW_BOLD
, IDS_FONT_BOLD_ITALIC
}
379 for (i
=0;i
<FSTYLES
;i
++)
381 lf
.lfItalic
=fontstyles
[i
].italic
;
382 lf
.lfWeight
=fontstyles
[i
].weight
;
383 hf
=CreateFontIndirectW(&lf
);
384 hf
=SelectObject(hdc
,hf
);
385 GetTextMetricsW(hdc
,&tm
);
386 hf
=SelectObject(hdc
,hf
);
388 /* font successful created ? */
389 if (((fontstyles
[i
].weight
== FW_NORMAL
&& tm
.tmWeight
<= FW_MEDIUM
) ||
390 (fontstyles
[i
].weight
== FW_BOLD
&& tm
.tmWeight
> FW_MEDIUM
)) &&
391 ((tm
.tmItalic
!= 0)==fontstyles
[i
].italic
))
394 LoadStringW(COMDLG32_hInstance
, fontstyles
[i
].resId
, name
, 64);
395 j
=SendMessageW(hwnd
,CB_ADDSTRING
,0,(LPARAM
)name
);
396 if (j
==CB_ERR
) return TRUE
;
397 j
=SendMessageW(hwnd
, CB_SETITEMDATA
, j
,
398 MAKELONG(tm
.tmWeight
,fontstyles
[i
].italic
));
399 if (j
==CB_ERR
) return TRUE
;
405 /*************************************************************************
406 * AddFontSizeToCombo3 [internal]
408 static BOOL
AddFontSizeToCombo3(HWND hwnd
, UINT h
, const CHOOSEFONTW
*lpcf
)
413 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
414 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
416 swprintf(buffer
, ARRAY_SIZE(buffer
), L
"%d", h
);
417 j
=SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buffer
);
420 j
=SendMessageW(hwnd
, CB_INSERTSTRING
, -1, (LPARAM
)buffer
);
421 if (j
!=CB_ERR
) j
= SendMessageW(hwnd
, CB_SETITEMDATA
, j
, h
);
422 if (j
==CB_ERR
) return TRUE
;
428 /*************************************************************************
429 * SetFontSizesToCombo3 [internal]
431 static BOOL
SetFontSizesToCombo3(HWND hwnd
, const CHOOSEFONTW
*lpcf
)
433 static const BYTE sizes
[]={6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
436 for (i
= 0; i
< ARRAY_SIZE(sizes
); i
++)
437 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return TRUE
;
441 /*************************************************************************
442 * CFn_GetDC [internal]
444 static inline HDC
CFn_GetDC(const CHOOSEFONTW
*lpcf
)
446 HDC ret
= ((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
) ?
449 if(!ret
) ERR("HDC failure!!!\n");
453 /*************************************************************************
454 * GetScreenDPI [internal]
456 static inline int GetScreenDPI(void)
462 result
= GetDeviceCaps(hdc
, LOGPIXELSY
);
468 /*************************************************************************
469 * CFn_ReleaseDC [internal]
471 static inline void CFn_ReleaseDC(const CHOOSEFONTW
*lpcf
, HDC hdc
)
473 if(!((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
))
477 /*************************************************************************
478 * select_combo_item [internal]
480 static void select_combo_item( HWND dialog
, int id
, int sel
)
482 HWND combo
= GetDlgItem( dialog
, id
);
483 SendMessageW( combo
, CB_SETCURSEL
, sel
, 0 );
484 SendMessageW( dialog
, WM_COMMAND
, MAKEWPARAM( id
, CBN_SELCHANGE
), (LPARAM
)combo
);
487 /***********************************************************************
488 * AddFontStyle [internal]
490 static INT
AddFontStyle( const ENUMLOGFONTEXW
*lpElfex
, const NEWTEXTMETRICEXW
*lpNTM
,
491 UINT nFontType
, const CHOOSEFONTW
*lpcf
, HWND hcmb2
, HWND hcmb3
, HWND hDlg
)
494 const LOGFONTW
*lplf
= &(lpElfex
->elfLogFont
);
498 TRACE("(nFontType=%d)\n",nFontType
);
499 TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
500 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
501 debugstr_w(lplf
->lfFaceName
),lplf
->lfHeight
,lplf
->lfWidth
,
502 lplf
->lfEscapement
,lplf
->lfOrientation
,
503 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
504 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
505 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
506 if (nFontType
& RASTER_FONTTYPE
)
509 points
= MulDiv( lpNTM
->ntmTm
.tmHeight
- lpNTM
->ntmTm
.tmInternalLeading
,
511 if (AddFontSizeToCombo3(hcmb3
, points
, lpcf
))
513 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
515 if (!SendMessageW(hcmb2
, CB_GETCOUNT
, 0, 0))
518 if(!(hdc
= CFn_GetDC(lpcf
))) return 0;
519 res
= SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
520 CFn_ReleaseDC(lpcf
, hdc
);
524 if (!( hcmb5
= GetDlgItem(hDlg
, cmb5
))) return 1;
525 i
= SendMessageW( hcmb5
, CB_FINDSTRINGEXACT
, 0,
526 (LPARAM
)lpElfex
->elfScript
);
528 i
= SendMessageW( hcmb5
, CB_ADDSTRING
, 0,
529 (LPARAM
)lpElfex
->elfScript
);
531 SendMessageW( hcmb5
, CB_SETITEMDATA
, i
, lplf
->lfCharSet
);
536 static void CFn_FitFontSize( HWND hDlg
, int points
)
540 /* look for fitting font size in combobox3 */
541 n
=SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCOUNT
, 0, 0);
544 if (points
== (int)SendDlgItemMessageW
545 (hDlg
,cmb3
, CB_GETITEMDATA
,i
,0))
547 select_combo_item( hDlg
, cmb3
, i
);
552 /* no default matching size, set text manually */
553 SetDlgItemInt(hDlg
, cmb3
, points
, TRUE
);
556 static BOOL
CFn_FitFontStyle( HWND hDlg
, LONG packedstyle
)
560 /* look for fitting font style in combobox2 */
561 for (i
=0;i
<TEXT_EXTRAS
;i
++)
563 id
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0);
564 if (packedstyle
== id
)
566 select_combo_item( hDlg
, cmb2
, i
);
574 static BOOL
CFn_FitCharSet( HWND hDlg
, int charset
)
577 /* look for fitting char set in combobox5 */
578 n
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCOUNT
, 0, 0);
581 cs
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, i
, 0);
584 select_combo_item( hDlg
, cmb5
, i
);
588 /* no charset fits: select the first one in the list */
589 select_combo_item( hDlg
, cmb5
, 0 );
593 /***********************************************************************
594 * FontStyleEnumProc32 [internal]
596 static INT WINAPI
FontStyleEnumProc( const ENUMLOGFONTEXW
*lpElfex
,
597 const TEXTMETRICW
*metrics
, DWORD dwFontType
, LPARAM lParam
)
599 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
602 HWND hDlg
=GetParent(hcmb3
);
603 return AddFontStyle( lpElfex
, (const NEWTEXTMETRICEXW
*) metrics
,
604 dwFontType
, s
->lpcf32w
, hcmb2
, hcmb3
, hDlg
);
607 /***********************************************************************
608 * CFn_WMInitDialog [internal]
610 static LRESULT
CFn_WMInitDialog(HWND hDlg
, LPARAM lParam
, LPCHOOSEFONTW lpcf
)
618 HCURSOR hcursor
=SetCursor(LoadCursorW(0,(LPWSTR
)IDC_WAIT
));
620 SetPropW(hDlg
, strWineFontData
, lpcf
);
621 lpxx
=lpcf
->lpLogFont
;
622 TRACE("WM_INITDIALOG lParam=%08IX\n", lParam
);
624 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONTW
))
626 ERR("structure size failure!!!\n");
631 himlTT
= ImageList_LoadImageW( COMDLG32_hInstance
, MAKEINTRESOURCEW(38),
632 TTBITMAP_XSIZE
, 0, CLR_DEFAULT
, IMAGE_BITMAP
, 0);
634 /* Set effect flags */
635 if((lpcf
->Flags
& CF_EFFECTS
) && (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
))
637 if(lpxx
->lfUnderline
)
638 CheckDlgButton(hDlg
, chx2
, TRUE
);
639 if(lpxx
->lfStrikeOut
)
640 CheckDlgButton(hDlg
, chx1
, TRUE
);
643 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow(lpcf
->hwndOwner
))
644 ShowWindow(GetDlgItem(hDlg
,pshHelp
),SW_HIDE
);
645 if (!(lpcf
->Flags
& CF_APPLY
))
646 ShowWindow(GetDlgItem(hDlg
,psh3
),SW_HIDE
);
647 if (lpcf
->Flags
& CF_NOSCRIPTSEL
)
648 EnableWindow(GetDlgItem(hDlg
,cmb5
),FALSE
);
649 if (lpcf
->Flags
& CF_EFFECTS
)
651 for (i
=0;i
<TEXT_COLORS
;i
++)
655 if (LoadStringW(COMDLG32_hInstance
, IDS_COLOR_BLACK
+i
, name
, ARRAY_SIZE(name
)) == 0)
656 lstrcpyW(name
, L
"[color name]");
657 j
=SendDlgItemMessageW(hDlg
, cmb4
, CB_ADDSTRING
, 0, (LPARAM
)name
);
658 SendDlgItemMessageW(hDlg
, cmb4
, CB_SETITEMDATA
, j
, textcolors
[i
]);
659 /* look for a fitting value in color combobox */
660 if (textcolors
[i
]==lpcf
->rgbColors
)
661 SendDlgItemMessageW(hDlg
,cmb4
, CB_SETCURSEL
,j
,0);
666 ShowWindow(GetDlgItem(hDlg
,cmb4
),SW_HIDE
);
667 ShowWindow(GetDlgItem(hDlg
,chx1
),SW_HIDE
);
668 ShowWindow(GetDlgItem(hDlg
,chx2
),SW_HIDE
);
669 ShowWindow(GetDlgItem(hDlg
,grp1
),SW_HIDE
);
670 ShowWindow(GetDlgItem(hDlg
,stc4
),SW_HIDE
);
672 if(!(hdc
= CFn_GetDC(lpcf
)))
677 s
.hWnd1
=GetDlgItem(hDlg
,cmb1
);
682 elf
.lfCharSet
= DEFAULT_CHARSET
; /* enum all charsets */
683 elf
.lfPitchAndFamily
= 0;
684 elf
.lfFaceName
[0] = '\0'; /* enum all fonts */
685 if (!EnumFontFamiliesExW(hdc
, &elf
, (FONTENUMPROCW
)FontFamilyEnumProc
, (LPARAM
)&s
, 0))
687 TRACE("EnumFontFamiliesEx returns 0\n");
691 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
) {
692 FIXME("No font found with fixed pitch only, dropping flag.\n");
693 lpcf
->Flags
&= ~CF_FIXEDPITCHONLY
;
696 if (lpcf
->Flags
& CF_TTONLY
) {
697 FIXME("No font found with truetype only, dropping flag.\n");
698 lpcf
->Flags
&= ~CF_TTONLY
;
705 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
707 /* look for fitting font name in combobox1 */
708 j
=SendDlgItemMessageW(hDlg
,cmb1
,CB_FINDSTRING
,-1,(LPARAM
)lpxx
->lfFaceName
);
711 INT height
= lpxx
->lfHeight
< 0 ? -lpxx
->lfHeight
:
714 int charset
= lpxx
->lfCharSet
;
715 points
= MulDiv( height
, 72, GetScreenDPI());
716 pstyle
= MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:
717 FW_NORMAL
,lpxx
->lfItalic
!=0);
718 select_combo_item( hDlg
, cmb1
, j
);
720 /* look for fitting font style in combobox2 */
721 CFn_FitFontStyle(hDlg
, pstyle
);
722 /* look for fitting font size in combobox3 */
723 CFn_FitFontSize(hDlg
, points
);
724 CFn_FitCharSet( hDlg
, charset
);
729 select_combo_item( hDlg
, cmb1
, 0 );
730 select_combo_item( hDlg
, cmb2
, 0 );
731 select_combo_item( hDlg
, cmb3
, 0 );
732 select_combo_item( hDlg
, cmb5
, 0 );
734 /* limit text length user can type in as font size */
735 SendDlgItemMessageW(hDlg
, cmb3
, CB_LIMITTEXT
, 5, 0);
737 if ((lpcf
->Flags
& CF_USESTYLE
) && lpcf
->lpszStyle
)
739 j
=SendDlgItemMessageW(hDlg
,cmb2
,CB_FINDSTRING
,-1,(LPARAM
)lpcf
->lpszStyle
);
740 if (j
!=CB_ERR
) select_combo_item( hDlg
, cmb2
, j
);
742 CFn_ReleaseDC(lpcf
, hdc
);
748 /***********************************************************************
749 * CFn_WMMeasureItem [internal]
751 static LRESULT
CFn_WMMeasureItem(HWND hDlg
, LPARAM lParam
)
756 LPMEASUREITEMSTRUCT lpmi
=(LPMEASUREITEMSTRUCT
)lParam
;
760 himlTT
= ImageList_LoadImageW( COMDLG32_hInstance
, MAKEINTRESOURCEW(38),
761 TTBITMAP_XSIZE
, 0, CLR_DEFAULT
, IMAGE_BITMAP
, 0);
762 ImageList_GetIconSize( himlTT
, &cx
, &height
);
763 lpmi
->itemHeight
= height
+ 2;
764 /* use MAX of bitmap height and tm.tmHeight .*/
767 hfontprev
= SelectObject( hdc
, (HFONT
)SendMessageW( hDlg
, WM_GETFONT
, 0, 0 ));
768 GetTextMetricsW(hdc
, &tm
);
769 if( tm
.tmHeight
> lpmi
->itemHeight
) lpmi
->itemHeight
= tm
.tmHeight
;
770 SelectObject(hdc
, hfontprev
);
771 ReleaseDC(hDlg
, hdc
);
776 /***********************************************************************
777 * CFn_WMDrawItem [internal]
779 static LRESULT
CFn_WMDrawItem(LPARAM lParam
)
783 COLORREF cr
, oldText
=0, oldBk
=0;
787 LPDRAWITEMSTRUCT lpdi
= (LPDRAWITEMSTRUCT
)lParam
;
789 if (lpdi
->itemID
== (UINT
)-1) /* got no items */
790 DrawFocusRect(lpdi
->hDC
, &lpdi
->rcItem
);
793 if (lpdi
->CtlType
== ODT_COMBOBOX
)
795 if (lpdi
->itemState
& ODS_SELECTED
)
797 hBrush
=GetSysColorBrush(COLOR_HIGHLIGHT
);
798 oldText
=SetTextColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHTTEXT
));
799 oldBk
=SetBkColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHT
));
802 hBrush
= SelectObject(lpdi
->hDC
, GetStockObject(LTGRAY_BRUSH
));
803 SelectObject(lpdi
->hDC
, hBrush
);
805 FillRect(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
808 return TRUE
; /* this should never happen */
814 /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
815 ImageList_GetIconSize( himlTT
, &cx
, &cy
);
816 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
818 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
+ cx
+ 4,
819 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
820 nFontType
= SendMessageW(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
822 if (nFontType
& TRUETYPE_FONTTYPE
) {
823 idx
= 0; /* picture: TT */
824 if( nFontType
& NTM_TT_OPENTYPE
)
825 idx
= 2; /* picture: O */
826 } else if( nFontType
& NTM_PS_OPENTYPE
)
827 idx
= 3; /* picture: O+ps */
828 else if( nFontType
& NTM_TYPE1
)
829 idx
= 4; /* picture: a */
830 else if( nFontType
& DEVICE_FONTTYPE
)
831 idx
= 1; /* picture: printer */
833 ImageList_Draw( himlTT
, idx
, lpdi
->hDC
, lpdi
->rcItem
.left
,
834 (lpdi
->rcItem
.top
+ lpdi
->rcItem
.bottom
- cy
) / 2, ILD_TRANSPARENT
);
838 /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
840 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
842 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
,
843 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
847 /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
848 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
850 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
851 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
852 cr
= SendMessageW(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
853 hBrush
= CreateSolidBrush(cr
);
856 hBrush
= SelectObject (lpdi
->hDC
, hBrush
) ;
857 rect
.right
=rect
.left
+25;
861 Rectangle( lpdi
->hDC
, rect
.left
, rect
.top
,
862 rect
.right
, rect
.bottom
);
863 DeleteObject( SelectObject (lpdi
->hDC
, hBrush
)) ;
870 return TRUE
; /* this should never happen */
872 if (lpdi
->itemState
& ODS_SELECTED
)
874 SetTextColor(lpdi
->hDC
, oldText
);
875 SetBkColor(lpdi
->hDC
, oldBk
);
881 static INT
get_dialog_font_point_size(HWND hDlg
, CHOOSEFONTW
*cf
)
883 BOOL invalid_size
= FALSE
;
886 i
= SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
888 size
= LOWORD(SendDlgItemMessageW(hDlg
, cmb3
, CB_GETITEMDATA
, i
, 0));
891 WCHAR buffW
[8], *endptrW
;
893 GetDlgItemTextW(hDlg
, cmb3
, buffW
, ARRAY_SIZE(buffW
));
894 size
= wcstol(buffW
, &endptrW
, 10);
895 invalid_size
= size
== 0 && *endptrW
;
901 cf
->iPointSize
= 10 * size
;
902 cf
->lpLogFont
->lfHeight
= -MulDiv(cf
->iPointSize
, GetScreenDPI(), 720);
903 return invalid_size
? -1 : size
;
906 /***********************************************************************
907 * CFn_WMCommand [internal]
909 static LRESULT
CFn_WMCommand(HWND hDlg
, WPARAM wParam
, LPARAM lParam
, LPCHOOSEFONTW lpcf
)
914 BOOL cmb_selected_by_edit
= FALSE
;
916 if (!lpcf
) return FALSE
;
918 if(HIWORD(wParam
) == CBN_EDITCHANGE
)
921 WCHAR str_edit
[256], str_cmb
[256];
922 int cmb
= LOWORD(wParam
);
924 GetDlgItemTextW(hDlg
, cmb
, str_edit
, ARRAY_SIZE(str_edit
));
925 idx
= SendDlgItemMessageW(hDlg
, cmb
, CB_FINDSTRING
, -1, (LPARAM
)str_edit
);
928 SendDlgItemMessageW(hDlg
, cmb
, CB_GETLBTEXT
, idx
, (LPARAM
)str_cmb
);
930 /* Select listbox entry only if we have an exact match */
931 if(lstrcmpiW(str_edit
, str_cmb
) == 0)
933 SendDlgItemMessageW(hDlg
, cmb
, CB_SETCURSEL
, idx
, 0);
934 SendDlgItemMessageW(hDlg
, cmb
, CB_SETEDITSEL
, 0, -1); /* Remove edit field selection */
935 cmb_selected_by_edit
= TRUE
;
940 TRACE("WM_COMMAND wParam=%08IX lParam=%08IX\n", wParam
, lParam
);
941 switch (LOWORD(wParam
))
944 if (HIWORD(wParam
) == CBN_SELCHANGE
|| cmb_selected_by_edit
)
946 INT pointsize
; /* save current pointsize */
947 LONG pstyle
; /* save current style */
950 if(!(hdc
= CFn_GetDC(lpcf
)))
955 idx
= SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
956 pointsize
= (int)SendDlgItemMessageW( hDlg
, cmb3
, CB_GETITEMDATA
,
958 idx
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
959 pstyle
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, idx
, 0);
960 idx
= SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCURSEL
, 0, 0);
961 charset
= SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, idx
, 0);
963 SendDlgItemMessageW(hDlg
, cmb2
, CB_RESETCONTENT
, 0, 0);
964 SendDlgItemMessageW(hDlg
, cmb3
, CB_RESETCONTENT
, 0, 0);
965 SendDlgItemMessageW(hDlg
, cmb5
, CB_RESETCONTENT
, 0, 0);
966 i
=SendDlgItemMessageW(hDlg
, cmb1
, CB_GETCURSEL
, 0, 0);
969 HCURSOR hcursor
=SetCursor(LoadCursorW(0,(LPWSTR
)IDC_WAIT
));
972 SendDlgItemMessageW(hDlg
, cmb1
, CB_GETLBTEXT
, i
,
973 (LPARAM
)enumlf
.lfFaceName
);
974 TRACE("WM_COMMAND/cmb1 =>%s\n", debugstr_w(enumlf
.lfFaceName
));
975 s
.hWnd1
=GetDlgItem(hDlg
, cmb2
);
976 s
.hWnd2
=GetDlgItem(hDlg
, cmb3
);
978 enumlf
.lfCharSet
= DEFAULT_CHARSET
; /* enum all charsets */
979 enumlf
.lfPitchAndFamily
= 0;
980 EnumFontFamiliesExW(hdc
, &enumlf
,
981 (FONTENUMPROCW
)FontStyleEnumProc
, (LPARAM
)&s
, 0);
982 CFn_FitFontStyle(hDlg
, pstyle
);
983 if( pointsize
!= CB_ERR
) CFn_FitFontSize(hDlg
, pointsize
);
984 if( charset
!= CB_ERR
) CFn_FitCharSet( hDlg
, charset
);
987 CFn_ReleaseDC(lpcf
, hdc
);
995 if (HIWORD(wParam
) == CBN_SELCHANGE
|| HIWORD(wParam
) == BN_CLICKED
|| cmb_selected_by_edit
)
999 LPLOGFONTW lpxx
=lpcf
->lpLogFont
;
1001 TRACE("WM_COMMAND/cmb2,3 =%08IX\n", lParam
);
1004 i
=SendDlgItemMessageW(hDlg
,cmb1
,CB_GETCURSEL
,0,0);
1006 GetDlgItemTextW( hDlg
, cmb1
, str
, ARRAY_SIZE(str
));
1009 SendDlgItemMessageW(hDlg
,cmb1
,CB_GETLBTEXT
,i
,
1011 l
=SendDlgItemMessageW(hDlg
,cmb1
,CB_GETITEMDATA
,i
,0);
1012 lpcf
->nFontType
= LOWORD(l
);
1013 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
1014 /* same value reported to the EnumFonts
1015 call back with the extra FONTTYPE_... bits added */
1016 lpxx
->lfPitchAndFamily
= HIWORD(l
) >> 8;
1018 lstrcpynW(lpxx
->lfFaceName
, str
, ARRAY_SIZE(lpxx
->lfFaceName
));
1021 i
=SendDlgItemMessageW(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1024 l
=SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0);
1025 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
1026 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
1027 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
1028 lpcf
->nFontType
|= BOLD_FONTTYPE
;
1032 get_dialog_font_point_size(hDlg
, lpcf
);
1035 if (lpcf
->Flags
& CF_NOSCRIPTSEL
)
1036 lpxx
->lfCharSet
= DEFAULT_CHARSET
;
1039 i
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCURSEL
, 0, 0);
1041 lpxx
->lfCharSet
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, i
, 0);
1043 lpxx
->lfCharSet
= DEFAULT_CHARSET
;
1045 lpxx
->lfStrikeOut
=IsDlgButtonChecked(hDlg
,chx1
);
1046 lpxx
->lfUnderline
=IsDlgButtonChecked(hDlg
,chx2
);
1047 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
1048 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
1049 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
1050 lpxx
->lfQuality
=DEFAULT_QUALITY
;
1052 wininfo
.cbSize
=sizeof(wininfo
);
1054 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1056 MapWindowPoints( 0, hDlg
, (LPPOINT
) &wininfo
.rcWindow
, 2);
1057 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1063 i
=SendDlgItemMessageW(hDlg
, cmb4
, CB_GETCURSEL
, 0, 0);
1068 lpcf
->rgbColors
= SendDlgItemMessageW(hDlg
, cmb4
, CB_GETITEMDATA
, i
, 0);
1069 wininfo
.cbSize
=sizeof(wininfo
);
1071 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1073 MapWindowPoints( 0, hDlg
, (LPPOINT
) &wininfo
.rcWindow
, 2);
1074 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1080 i
=RegisterWindowMessageW( HELPMSGSTRINGW
);
1081 if (lpcf
->hwndOwner
)
1082 SendMessageW(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetPropW(hDlg
, strWineFontData
));
1090 pointsize
= get_dialog_font_point_size(hDlg
, lpcf
);
1091 if (pointsize
== -1)
1093 LoadStringW(COMDLG32_hInstance
, IDS_FONT_SIZE_INPUT
, msgW
, ARRAY_SIZE(msgW
));
1094 MessageBoxW(hDlg
, msgW
, NULL
, MB_OK
| MB_ICONINFORMATION
);
1098 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
1099 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
1100 (lpcf
->iPointSize
>= 10 * lpcf
->nSizeMin
) &&
1101 (lpcf
->iPointSize
<= 10 * lpcf
->nSizeMax
)))
1102 EndDialog(hDlg
, TRUE
);
1107 LoadStringW(COMDLG32_hInstance
, IDS_FONT_SIZE
, format
, ARRAY_SIZE(format
));
1108 args
[0] = lpcf
->nSizeMin
;
1109 args
[1] = lpcf
->nSizeMax
;
1110 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1111 format
, 0, 0, msgW
, ARRAY_SIZE(msgW
), (va_list *)args
);
1112 MessageBoxW(hDlg
, msgW
, NULL
, MB_OK
);
1117 EndDialog(hDlg
, FALSE
);
1123 static LRESULT
CFn_WMDestroy(HWND hwnd
, LPCHOOSEFONTW lpcfw
)
1125 LPCHOOSEFONTA lpcfa
;
1127 LPLOGFONTA lpLogFonta
;
1130 if (!lpcfw
) return FALSE
;
1132 lpcfa
= GetPropW(hwnd
, strWineFontData_a
);
1133 lpLogFonta
= lpcfa
->lpLogFont
;
1134 lpszStyle
= lpcfa
->lpszStyle
;
1135 memcpy(lpcfa
, lpcfw
, sizeof(CHOOSEFONTA
));
1136 lpcfa
->lpLogFont
= lpLogFonta
;
1137 lpcfa
->lpszStyle
= lpszStyle
;
1138 memcpy(lpcfa
->lpLogFont
, lpcfw
->lpLogFont
, sizeof(LOGFONTA
));
1139 WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpLogFont
->lfFaceName
,
1140 LF_FACESIZE
, lpcfa
->lpLogFont
->lfFaceName
, LF_FACESIZE
, 0, 0);
1142 if((lpcfw
->Flags
& CF_USESTYLE
) && lpcfw
->lpszStyle
) {
1143 len
= WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpszStyle
, -1, NULL
, 0, 0, 0);
1144 WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpszStyle
, -1, lpcfa
->lpszStyle
, len
, 0, 0);
1145 heap_free(lpcfw
->lpszStyle
);
1148 heap_free(lpcfw
->lpLogFont
);
1150 SetPropW(hwnd
, strWineFontData
, 0);
1155 static LRESULT
CFn_WMPaint(HWND hDlg
, WPARAM wParam
, LPARAM lParam
, const CHOOSEFONTW
*lpcf
)
1159 if (!lpcf
) return FALSE
;
1161 info
.cbSize
=sizeof(info
);
1162 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &info
) )
1167 LOGFONTW lf
= *(lpcf
->lpLogFont
);
1169 MapWindowPoints( 0, hDlg
, (LPPOINT
) &info
.rcWindow
, 2);
1170 hdc
= BeginPaint( hDlg
, &ps
);
1172 TRACE("erase %d, rect=%s\n", ps
.fErase
, wine_dbgstr_rect(&ps
.rcPaint
));
1175 DrawEdge( hdc
, &info
.rcWindow
, EDGE_SUNKEN
, BF_RECT
|BF_ADJUST
);
1177 /* Draw the sample text itself */
1178 hOrigFont
= SelectObject( hdc
, CreateFontIndirectW( &lf
) );
1179 SetTextColor( hdc
, lpcf
->rgbColors
);
1180 SetBkMode( hdc
, TRANSPARENT
);
1183 sample_lang_text
[CHARSET_ORDER
[lpcf
->lpLogFont
->lfCharSet
]],
1184 -1, &info
.rcWindow
, DT_CENTER
|DT_VCENTER
|DT_SINGLELINE
);
1186 DeleteObject(SelectObject( hdc
, hOrigFont
));
1187 EndPaint( hDlg
, &ps
);
1192 /***********************************************************************
1193 * FormatCharDlgProcA [internal]
1195 static INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1197 LPCHOOSEFONTW lpcfw
;
1198 LPCHOOSEFONTA lpcfa
;
1199 INT_PTR res
= FALSE
;
1202 if (uMsg
!=WM_INITDIALOG
) {
1203 lpcfw
= GetPropW(hDlg
, strWineFontData
);
1204 if (lpcfw
&& CFn_HookCallChk32(lpcfw
))
1205 res
=CallWindowProcA((WNDPROC
)lpcfw
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1209 lpcfa
=(LPCHOOSEFONTA
)lParam
;
1210 SetPropW(hDlg
, strWineFontData_a
, (HANDLE
)lParam
);
1212 lpcfw
= heap_alloc(sizeof(*lpcfw
));
1213 memcpy(lpcfw
, lpcfa
, sizeof(CHOOSEFONTA
));
1214 lpcfw
->lpLogFont
= heap_alloc(sizeof(*lpcfw
->lpLogFont
));
1215 memcpy(lpcfw
->lpLogFont
, lpcfa
->lpLogFont
, sizeof(LOGFONTA
));
1216 MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpLogFont
->lfFaceName
,
1217 LF_FACESIZE
, lpcfw
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
1219 if((lpcfa
->Flags
& CF_USESTYLE
) && lpcfa
->lpszStyle
) {
1220 len
= MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpszStyle
, -1, NULL
, 0);
1221 lpcfw
->lpszStyle
= heap_alloc(len
* sizeof(WCHAR
));
1222 MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpszStyle
, -1, lpcfw
->lpszStyle
, len
);
1225 if (!CFn_WMInitDialog(hDlg
, lParam
, lpcfw
))
1227 TRACE("CFn_WMInitDialog returned FALSE\n");
1230 if (CFn_HookCallChk32(lpcfw
))
1231 return CallWindowProcA((WNDPROC
)lpcfa
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1235 case WM_MEASUREITEM
:
1236 return CFn_WMMeasureItem(hDlg
,lParam
);
1238 return CFn_WMDrawItem(lParam
);
1240 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcfw
);
1242 return CFn_WMDestroy(hDlg
, lpcfw
);
1243 case WM_CHOOSEFONT_GETLOGFONT
:
1245 LOGFONTA
*logfont
= (LOGFONTA
*)lParam
;
1246 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08IX\n", lParam
);
1247 memcpy( logfont
, lpcfw
->lpLogFont
, FIELD_OFFSET( LOGFONTA
, lfFaceName
));
1248 WideCharToMultiByte( CP_ACP
, 0, lpcfw
->lpLogFont
->lfFaceName
, LF_FACESIZE
,
1249 logfont
->lfFaceName
, LF_FACESIZE
, NULL
, NULL
);
1253 return CFn_WMPaint(hDlg
, wParam
, lParam
, lpcfw
);
1258 /***********************************************************************
1259 * FormatCharDlgProcW [internal]
1261 static INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1264 INT_PTR res
= FALSE
;
1266 if (uMsg
!=WM_INITDIALOG
)
1268 lpcf
= GetPropW(hDlg
, strWineFontData
);
1269 if (lpcf
&& CFn_HookCallChk32(lpcf
))
1270 res
=CallWindowProcW((WNDPROC
)lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1276 lpcf
=(LPCHOOSEFONTW
)lParam
;
1277 if (!CFn_WMInitDialog(hDlg
, lParam
, lpcf
))
1279 TRACE("CFn_WMInitDialog returned FALSE\n");
1282 if (CFn_HookCallChk32(lpcf
))
1283 return CallWindowProcW((WNDPROC
)lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1287 case WM_MEASUREITEM
:
1288 return CFn_WMMeasureItem(hDlg
, lParam
);
1290 return CFn_WMDrawItem(lParam
);
1292 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
1295 case WM_CHOOSEFONT_GETLOGFONT
:
1296 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08IX\n", lParam
);
1297 memcpy( (LOGFONTW
*)lParam
, lpcf
->lpLogFont
, sizeof(LOGFONTW
) );
1300 return CFn_WMPaint(hDlg
, wParam
, lParam
, lpcf
);