Added basic support for SPI_GETSCREENREADER.
[wine/multimedia.git] / dlls / commdlg / fontdlg.c
blob533df379691a858e276fe67ed528329aa6943177
1 /*
2 * COMMDLG - Font Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 */
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include "windef.h"
13 #include "winnls.h"
14 #include "winbase.h"
15 #include "wingdi.h"
16 #include "wine/winbase16.h"
17 #include "wine/winuser16.h"
18 #include "heap.h"
19 #include "commdlg.h"
20 #include "dlgs.h"
21 #include "debugtools.h"
22 #include "cderr.h"
24 DEFAULT_DEBUG_CHANNEL(commdlg);
26 #include "cdlg.h"
28 static HBITMAP16 hBitmapTT = 0;
31 LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
32 LPARAM lParam);
33 LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
34 LPARAM lParam);
35 LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
36 LPARAM lParam);
38 static void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 )
40 font32->lfHeight = font16->lfHeight;
41 font32->lfWidth = font16->lfWidth;
42 font32->lfEscapement = font16->lfEscapement;
43 font32->lfOrientation = font16->lfOrientation;
44 font32->lfWeight = font16->lfWeight;
45 font32->lfItalic = font16->lfItalic;
46 font32->lfUnderline = font16->lfUnderline;
47 font32->lfStrikeOut = font16->lfStrikeOut;
48 font32->lfCharSet = font16->lfCharSet;
49 font32->lfOutPrecision = font16->lfOutPrecision;
50 font32->lfClipPrecision = font16->lfClipPrecision;
51 font32->lfQuality = font16->lfQuality;
52 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
53 lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
56 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
58 chf32a->lStructSize=sizeof(CHOOSEFONTA);
59 chf32a->hwndOwner=chf16->hwndOwner;
60 chf32a->hDC=chf16->hDC;
61 chf32a->iPointSize=chf16->iPointSize;
62 chf32a->Flags=chf16->Flags;
63 chf32a->rgbColors=chf16->rgbColors;
64 chf32a->lCustData=chf16->lCustData;
65 chf32a->lpfnHook=NULL;
66 chf32a->lpTemplateName=MapSL(chf16->lpTemplateName);
67 chf32a->hInstance=chf16->hInstance;
68 chf32a->lpszStyle=MapSL(chf16->lpszStyle);
69 chf32a->nFontType=chf16->nFontType;
70 chf32a->nSizeMax=chf16->nSizeMax;
71 chf32a->nSizeMin=chf16->nSizeMin;
72 FONT_LogFont16To32A(MapSL(chf16->lpLogFont), chf32a->lpLogFont);
75 struct {
76 int mask;
77 char *name;
78 } cfflags[] = {
79 #define XX(x) { x, #x },
80 XX(CF_SCREENFONTS)
81 XX(CF_PRINTERFONTS)
82 XX(CF_SHOWHELP)
83 XX(CF_ENABLEHOOK)
84 XX(CF_ENABLETEMPLATE)
85 XX(CF_ENABLETEMPLATEHANDLE)
86 XX(CF_INITTOLOGFONTSTRUCT)
87 XX(CF_USESTYLE)
88 XX(CF_EFFECTS)
89 XX(CF_APPLY)
90 XX(CF_ANSIONLY)
91 XX(CF_NOVECTORFONTS)
92 XX(CF_NOSIMULATIONS)
93 XX(CF_LIMITSIZE)
94 XX(CF_FIXEDPITCHONLY)
95 XX(CF_WYSIWYG)
96 XX(CF_FORCEFONTEXIST)
97 XX(CF_SCALABLEONLY)
98 XX(CF_TTONLY)
99 XX(CF_NOFACESEL)
100 XX(CF_NOSTYLESEL)
101 XX(CF_NOSIZESEL)
102 XX(CF_SELECTSCRIPT)
103 XX(CF_NOSCRIPTSEL)
104 XX(CF_NOVERTFONTS)
105 #undef XX
106 {0,NULL},
109 static void
110 _dump_cf_flags(DWORD cflags) {
111 int i;
113 for (i=0;cfflags[i].name;i++)
114 if (cfflags[i].mask & cflags)
115 MESSAGE("%s|",cfflags[i].name);
116 MESSAGE("\n");
120 /***********************************************************************
121 * ChooseFont16 (COMMDLG.15)
123 BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
125 HINSTANCE16 hInst;
126 HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
127 HGLOBAL16 hGlobal16 = 0;
128 BOOL16 bRet = FALSE;
129 LPCVOID template;
130 FARPROC16 ptr;
131 CHOOSEFONTA cf32a;
132 LOGFONTA lf32a;
133 LOGFONT16 *font16;
134 SEGPTR lpTemplateName;
136 cf32a.lpLogFont=&lf32a;
137 CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
139 TRACE("ChooseFont\n");
140 if (!lpChFont) return FALSE;
142 if (TRACE_ON(commdlg))
143 _dump_cf_flags(lpChFont->Flags);
145 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
147 if (!(template = LockResource16( lpChFont->hInstance )))
149 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
150 return FALSE;
153 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
155 HANDLE16 hResInfo;
156 if (!(hResInfo = FindResource16( lpChFont->hInstance,
157 MapSL(lpChFont->lpTemplateName),
158 RT_DIALOGA)))
160 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
161 return FALSE;
163 if (!(hDlgTmpl16 = LoadResource16( lpChFont->hInstance, hResInfo )) ||
164 !(template = LockResource16( hDlgTmpl16 )))
166 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
167 return FALSE;
170 else
172 HANDLE hResInfo, hDlgTmpl32;
173 LPCVOID template32;
174 DWORD size;
175 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
177 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
178 return FALSE;
180 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
181 !(template32 = LockResource(hDlgTmpl32)))
183 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
184 return FALSE;
186 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
187 hGlobal16 = GlobalAlloc16(0, size);
188 if (!hGlobal16)
190 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
191 ERR("alloc failure for %ld bytes\n", size);
192 return FALSE;
194 template = GlobalLock16(hGlobal16);
195 if (!template)
197 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
198 ERR("global lock failure for %x handle\n", hGlobal16);
199 GlobalFree16(hGlobal16);
200 return FALSE;
202 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
203 hDlgTmpl16 = hGlobal16;
207 /* lpTemplateName is not used in the dialog */
208 lpTemplateName=lpChFont->lpTemplateName;
209 lpChFont->lpTemplateName=(SEGPTR)&cf32a;
211 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 16);
212 hInst = GetWindowLongA(lpChFont->hwndOwner, GWL_HINSTANCE);
213 bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChFont->hwndOwner,
214 (DLGPROC16) ptr, (DWORD)lpChFont);
215 if (hResource16) FreeResource16(hDlgTmpl16);
216 if (hGlobal16)
218 GlobalUnlock16(hGlobal16);
219 GlobalFree16(hGlobal16);
221 lpChFont->lpTemplateName=lpTemplateName;
224 font16 = MapSL(lpChFont->lpLogFont);
225 font16->lfHeight = cf32a.lpLogFont->lfHeight;
226 font16->lfWidth = cf32a.lpLogFont->lfWidth;
227 font16->lfEscapement = cf32a.lpLogFont->lfEscapement;
228 font16->lfOrientation = cf32a.lpLogFont->lfOrientation;
229 font16->lfWeight = cf32a.lpLogFont->lfWeight;
230 font16->lfItalic = cf32a.lpLogFont->lfItalic;
231 font16->lfUnderline = cf32a.lpLogFont->lfUnderline;
232 font16->lfStrikeOut = cf32a.lpLogFont->lfStrikeOut;
233 font16->lfCharSet = cf32a.lpLogFont->lfCharSet;
234 font16->lfOutPrecision = cf32a.lpLogFont->lfOutPrecision;
235 font16->lfClipPrecision = cf32a.lpLogFont->lfClipPrecision;
236 font16->lfQuality = cf32a.lpLogFont->lfQuality;
237 font16->lfPitchAndFamily = cf32a.lpLogFont->lfPitchAndFamily;
238 lstrcpynA( font16->lfFaceName, cf32a.lpLogFont->lfFaceName, LF_FACESIZE );
239 return bRet;
243 /***********************************************************************
244 * ChooseFontA (COMDLG32.3)
246 BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
248 LPCVOID template;
249 HANDLE hResInfo, hDlgTmpl;
251 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
253 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
254 return FALSE;
256 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
257 !(template = LockResource( hDlgTmpl )))
259 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
260 return FALSE;
262 if (TRACE_ON(commdlg))
263 _dump_cf_flags(lpChFont->Flags);
265 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
266 CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
267 return DialogBoxIndirectParamA(COMMDLG_hInstance32, template,
268 lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcA, (LPARAM)lpChFont );
271 /***********************************************************************
272 * ChooseFontW (COMDLG32.4)
274 BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
276 BOOL bRet=FALSE;
277 CHOOSEFONTA cf32a;
278 LOGFONTA lf32a;
279 LPCVOID template;
280 HANDLE hResInfo, hDlgTmpl;
282 if (TRACE_ON(commdlg))
283 _dump_cf_flags(lpChFont->Flags);
285 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
287 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
288 return FALSE;
290 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
291 !(template = LockResource( hDlgTmpl )))
293 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
294 return FALSE;
297 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
298 CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
299 memcpy(&cf32a, lpChFont, sizeof(cf32a));
300 memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA));
302 WideCharToMultiByte( CP_ACP, 0, lpChFont->lpLogFont->lfFaceName, -1,
303 lf32a.lfFaceName, LF_FACESIZE, NULL, NULL );
304 lf32a.lfFaceName[LF_FACESIZE-1] = 0;
305 cf32a.lpLogFont=&lf32a;
306 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
307 lpChFont->lpTemplateName=(LPWSTR)&cf32a;
308 bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template,
309 lpChFont->hwndOwner, (DLGPROC)FormatCharDlgProcW, (LPARAM)lpChFont );
310 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
311 lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
312 memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
313 MultiByteToWideChar( CP_ACP, 0, lf32a.lfFaceName, -1,
314 lpChFont->lpLogFont->lfFaceName, LF_FACESIZE );
315 lpChFont->lpLogFont->lfFaceName[LF_FACESIZE-1] = 0;
316 return bRet;
320 #define TEXT_EXTRAS 4
321 #define TEXT_COLORS 16
323 static const COLORREF textcolors[TEXT_COLORS]=
325 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
326 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
327 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
328 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
331 /***********************************************************************
332 * CFn_HookCallChk [internal]
334 static BOOL CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
336 if (lpcf)
337 if(lpcf->Flags & CF_ENABLEHOOK)
338 if (lpcf->lpfnHook)
339 return TRUE;
340 return FALSE;
343 /***********************************************************************
344 * CFn_HookCallChk32 [internal]
346 static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
348 if (lpcf)
349 if(lpcf->Flags & CF_ENABLEHOOK)
350 if (lpcf->lpfnHook)
351 return TRUE;
352 return FALSE;
355 typedef struct
357 HWND hWnd1;
358 HWND hWnd2;
359 LPCHOOSEFONTA lpcf32a;
360 int added;
361 } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
363 /*************************************************************************
364 * AddFontFamily [internal]
366 static INT AddFontFamily(const LOGFONTA *lplf, UINT nFontType,
367 LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
369 int i;
370 WORD w;
372 TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
374 if (lpcf->Flags & CF_FIXEDPITCHONLY)
375 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
376 return 1;
377 if (lpcf->Flags & CF_ANSIONLY)
378 if (lplf->lfCharSet != ANSI_CHARSET)
379 return 1;
380 if (lpcf->Flags & CF_TTONLY)
381 if (!(nFontType & TRUETYPE_FONTTYPE))
382 return 1;
384 if (e) e->added++;
386 i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
387 if (i!=CB_ERR)
389 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
390 SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
391 return 1 ; /* store some important font information */
393 else
394 return 0;
397 /*************************************************************************
398 * FontFamilyEnumProc32 [internal]
400 static INT WINAPI FontFamilyEnumProc(const LOGFONTA *lpLogFont,
401 const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam)
403 LPCFn_ENUMSTRUCT e;
404 e=(LPCFn_ENUMSTRUCT)lParam;
405 return AddFontFamily(lpLogFont, dwFontType, e->lpcf32a, e->hWnd1, e);
408 /***********************************************************************
409 * FontFamilyEnumProc16 (COMMDLG.19)
411 INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
412 UINT16 nFontType, LPARAM lParam )
414 HWND16 hwnd=LOWORD(lParam);
415 HWND hDlg=GetParent(hwnd);
416 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
417 LOGFONT16 *lplf = MapSL( logfont );
418 LOGFONTA lf32a;
419 FONT_LogFont16To32A(lplf, &lf32a);
420 return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
421 hwnd,NULL);
424 /*************************************************************************
425 * SetFontStylesToCombo2 [internal]
427 * Fill font style information into combobox (without using font.c directly)
429 static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTA *lplf)
431 #define FSTYLES 4
432 struct FONTSTYLE
433 { int italic;
434 int weight;
435 char stname[20]; };
436 static struct FONTSTYLE fontstyles[FSTYLES]={
437 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
438 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
439 HFONT hf;
440 TEXTMETRICA tm;
441 int i,j;
442 LOGFONTA lf;
444 memcpy(&lf, lplf, sizeof(LOGFONTA));
446 for (i=0;i<FSTYLES;i++)
448 lf.lfItalic=fontstyles[i].italic;
449 lf.lfWeight=fontstyles[i].weight;
450 hf=CreateFontIndirectA(&lf);
451 hf=SelectObject(hdc,hf);
452 GetTextMetricsA(hdc,&tm);
453 hf=SelectObject(hdc,hf);
454 DeleteObject(hf);
456 if (tm.tmWeight==fontstyles[i].weight &&
457 tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
459 j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)fontstyles[i].stname );
460 if (j==CB_ERR) return 1;
461 j=SendMessageA(hwnd, CB_SETITEMDATA, j,
462 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
463 if (j==CB_ERR) return 1;
466 return 0;
469 /*************************************************************************
470 * AddFontSizeToCombo3 [internal]
472 static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
474 int j;
475 char buffer[20];
477 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
478 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
480 sprintf(buffer, "%2d", h);
481 j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
482 if (j==CB_ERR)
484 j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
485 if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
486 if (j==CB_ERR) return 1;
489 return 0;
492 /*************************************************************************
493 * SetFontSizesToCombo3 [internal]
495 static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
497 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
498 int i;
500 for (i=0; sizes[i]; i++)
501 if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
502 return 0;
505 /***********************************************************************
506 * AddFontStyle [internal]
508 static INT AddFontStyle(const LOGFONTA *lplf, UINT nFontType,
509 LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
511 int i;
513 TRACE("(nFontType=%d)\n",nFontType);
514 TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
515 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
516 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
517 lplf->lfEscapement,lplf->lfOrientation,
518 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
519 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
520 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
521 if (nFontType & RASTER_FONTTYPE)
523 if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
524 } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
526 if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
528 HDC hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
529 i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
530 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
531 ReleaseDC(hDlg,hdc);
532 if (i)
533 return 0;
535 return 1 ;
539 /***********************************************************************
540 * FontStyleEnumProc16 (COMMDLG.18)
542 INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
543 UINT16 nFontType, LPARAM lParam )
545 HWND16 hcmb2=LOWORD(lParam);
546 HWND16 hcmb3=HIWORD(lParam);
547 HWND hDlg=GetParent(hcmb3);
548 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
549 LOGFONT16 *lplf = MapSL(logfont);
550 LOGFONTA lf32a;
551 FONT_LogFont16To32A(lplf, &lf32a);
552 return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
553 hcmb2, hcmb3, hDlg);
556 /***********************************************************************
557 * FontStyleEnumProc32 [internal]
559 static INT WINAPI FontStyleEnumProc( const LOGFONTA *lpFont,
560 const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam )
562 LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
563 HWND hcmb2=s->hWnd1;
564 HWND hcmb3=s->hWnd2;
565 HWND hDlg=GetParent(hcmb3);
566 return AddFontStyle(lpFont, dwFontType, s->lpcf32a, hcmb2,
567 hcmb3, hDlg);
570 /***********************************************************************
571 * CFn_WMInitDialog [internal]
573 static LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
574 LPCHOOSEFONTA lpcf)
576 HDC hdc;
577 int i,j,res,init=0;
578 long l;
579 LPLOGFONTA lpxx;
580 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
582 SetWindowLongA(hDlg, DWL_USER, lParam);
583 lpxx=lpcf->lpLogFont;
584 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
586 if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
588 ERR("structure size failure !!!\n");
589 EndDialog (hDlg, 0);
590 return FALSE;
592 if (!hBitmapTT)
593 hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
595 /* This font will be deleted by WM_COMMAND */
596 SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,
597 CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
599 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
600 ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
601 if (!(lpcf->Flags & CF_APPLY))
602 ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
603 if (lpcf->Flags & CF_EFFECTS)
605 for (res=1,i=0;res && i<TEXT_COLORS;i++)
607 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
608 char name[20];
609 strcpy( name, "[color name]" );
610 j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
611 SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
612 /* look for a fitting value in color combobox */
613 if (textcolors[j]==lpcf->rgbColors)
614 SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
617 else
619 ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
620 ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
621 ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
622 ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
623 ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
625 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
626 if (hdc)
628 CFn_ENUMSTRUCT s;
629 s.hWnd1=GetDlgItem(hDlg,cmb1);
630 s.lpcf32a=lpcf;
631 do {
632 s.added = 0;
633 if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s)) {
634 TRACE("EnumFontFamilies returns 0\n");
635 break;
637 if (s.added) break;
638 if (lpcf->Flags & CF_FIXEDPITCHONLY) {
639 FIXME("No founds found with fixed pitch only, dropping flag.\n");
640 lpcf->Flags &= ~CF_FIXEDPITCHONLY;
641 continue;
643 if (lpcf->Flags & CF_TTONLY) {
644 FIXME("No founds found with truetype only, dropping flag.\n");
645 lpcf->Flags &= ~CF_TTONLY;
646 continue;
648 break;
649 } while (1);
652 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
654 /* look for fitting font name in combobox1 */
655 j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
656 if (j!=CB_ERR)
658 SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
659 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
660 GetDlgItem(hDlg,cmb1));
661 init=1;
662 /* look for fitting font style in combobox2 */
663 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
664 for (i=0;i<TEXT_EXTRAS;i++)
666 if (l==SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0))
667 SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
670 /* look for fitting font size in combobox3 */
671 j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
672 for (i=0;i<j;i++)
674 if (lpxx->lfHeight==(int)SendDlgItemMessageA(hDlg,cmb3, CB_GETITEMDATA,i,0))
675 SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
679 if (!init)
681 SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
682 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
683 GetDlgItem(hDlg,cmb1));
685 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
687 j=SendDlgItemMessageA(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
688 if (j!=CB_ERR)
690 j=SendDlgItemMessageA(hDlg,cmb2,CB_SETCURSEL,j,0);
691 SendMessageA(hDlg,WM_COMMAND,cmb2,
692 MAKELONG(GetDlgItem(hDlg,cmb2),CBN_SELCHANGE));
696 else
698 WARN("HDC failure !!!\n");
699 EndDialog (hDlg, 0);
700 return FALSE;
703 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
704 ReleaseDC(hDlg,hdc);
705 SetCursor(hcursor);
706 return TRUE;
710 /***********************************************************************
711 * CFn_WMMeasureItem [internal]
713 static LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
715 BITMAP bm;
716 LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
717 if (!hBitmapTT)
718 hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
719 GetObjectA( hBitmapTT, sizeof(bm), &bm );
720 lpmi->itemHeight=bm.bmHeight;
721 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
722 return 0;
726 /***********************************************************************
727 * CFn_WMDrawItem [internal]
729 static LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
731 HBRUSH hBrush;
732 char buffer[40];
733 BITMAP bm;
734 COLORREF cr, oldText=0, oldBk=0;
735 RECT rect;
736 #if 0
737 HDC hMemDC;
738 int nFontType;
739 HBITMAP hBitmap; /* for later TT usage */
740 #endif
741 LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
743 if (lpdi->itemID == 0xFFFF) /* got no items */
744 DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
745 else
747 if (lpdi->CtlType == ODT_COMBOBOX)
749 if (lpdi->itemState ==ODS_SELECTED)
751 hBrush=GetSysColorBrush(COLOR_HIGHLIGHT);
752 oldText=SetTextColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
753 oldBk=SetBkColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHT));
754 } else
756 hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
757 SelectObject(lpdi->hDC, hBrush);
759 FillRect(lpdi->hDC, &lpdi->rcItem, hBrush);
761 else
762 return TRUE; /* this should never happen */
764 rect=lpdi->rcItem;
765 switch (lpdi->CtlID)
767 case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
768 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
769 (LPARAM)buffer);
770 GetObjectA( hBitmapTT, sizeof(bm), &bm );
771 TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
772 lpdi->rcItem.top, buffer, strlen(buffer));
773 #if 0
774 nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
775 /* FIXME: draw bitmap if truetype usage */
776 if (nFontType&TRUETYPE_FONTTYPE)
778 hMemDC = CreateCompatibleDC(lpdi->hDC);
779 hBitmap = SelectObject(hMemDC, hBitmapTT);
780 BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
781 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
782 SelectObject(hMemDC, hBitmap);
783 DeleteDC(hMemDC);
785 #endif
786 break;
787 case cmb2:
788 case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
789 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
790 (LPARAM)buffer);
791 TextOutA(lpdi->hDC, lpdi->rcItem.left,
792 lpdi->rcItem.top, buffer, strlen(buffer));
793 break;
795 case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
796 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
797 (LPARAM)buffer);
798 TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
799 lpdi->rcItem.top, buffer, strlen(buffer));
800 cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
801 hBrush = CreateSolidBrush(cr);
802 if (hBrush)
804 hBrush = SelectObject (lpdi->hDC, hBrush) ;
805 rect.right=rect.left+25;
806 rect.top++;
807 rect.left+=5;
808 rect.bottom--;
809 Rectangle( lpdi->hDC, rect.left, rect.top,
810 rect.right, rect.bottom );
811 DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
813 rect=lpdi->rcItem;
814 rect.left+=25+5;
815 break;
817 default: return TRUE; /* this should never happen */
819 if (lpdi->itemState == ODS_SELECTED)
821 SetTextColor(lpdi->hDC, oldText);
822 SetBkColor(lpdi->hDC, oldBk);
825 return TRUE;
828 /***********************************************************************
829 * CFn_WMCtlColor [internal]
831 static LRESULT CFn_WMCtlColorStatic(HWND hDlg, WPARAM wParam, LPARAM lParam,
832 LPCHOOSEFONTA lpcf)
834 if (lpcf->Flags & CF_EFFECTS)
835 if (GetDlgCtrlID(lParam)==stc6)
837 SetTextColor((HDC)wParam, lpcf->rgbColors);
838 return GetStockObject(WHITE_BRUSH);
840 return 0;
843 /***********************************************************************
844 * CFn_WMCommand [internal]
846 static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
847 LPCHOOSEFONTA lpcf)
849 HFONT hFont;
850 int i,j;
851 long l;
852 HDC hdc;
853 LPLOGFONTA lpxx=lpcf->lpLogFont;
855 TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
856 switch (LOWORD(wParam))
858 case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
860 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
861 if (hdc)
863 SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
864 SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
865 i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
866 if (i!=CB_ERR)
868 HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
869 CFn_ENUMSTRUCT s;
870 char str[256];
871 SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
872 (LPARAM)str);
873 TRACE("WM_COMMAND/cmb1 =>%s\n",str);
874 s.hWnd1=GetDlgItem(hDlg, cmb2);
875 s.hWnd2=GetDlgItem(hDlg, cmb3);
876 s.lpcf32a=lpcf;
877 EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
878 SendDlgItemMessageA(hDlg,cmb2, CB_SETCURSEL, 0, 0);
879 SendDlgItemMessageA(hDlg,cmb3, CB_SETCURSEL, 0, 0);
880 SetCursor(hcursor);
882 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
883 ReleaseDC(hDlg,hdc);
885 else
887 WARN("HDC failure !!!\n");
888 EndDialog (hDlg, 0);
889 return TRUE;
892 case chx1:
893 case chx2:
894 case cmb2:
895 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
897 char str[256];
898 TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
899 i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
900 if (i==CB_ERR)
901 i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
902 else
904 SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
905 (LPARAM)str);
906 l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
907 j=HIWORD(l);
908 lpcf->nFontType = LOWORD(l);
909 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
910 /* same value reported to the EnumFonts
911 call back with the extra FONTTYPE_... bits added */
912 lpxx->lfPitchAndFamily=j&0xff;
913 lpxx->lfCharSet=j>>8;
915 strcpy(lpxx->lfFaceName,str);
916 i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
917 if (i!=CB_ERR)
919 l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
920 if (0!=(lpxx->lfItalic=HIWORD(l)))
921 lpcf->nFontType |= ITALIC_FONTTYPE;
922 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
923 lpcf->nFontType |= BOLD_FONTTYPE;
925 i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
926 if (i!=CB_ERR)
927 lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
928 else
929 lpxx->lfHeight=0;
930 lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
931 lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
932 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
933 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
934 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
935 lpxx->lfQuality=DEFAULT_QUALITY;
936 lpcf->iPointSize= -10*lpxx->lfHeight;
938 hFont=CreateFontIndirectA(lpxx);
939 if (hFont)
941 HFONT oldFont=SendDlgItemMessageA(hDlg, stc6,
942 WM_GETFONT, 0, 0);
943 SendDlgItemMessageA(hDlg,stc6,WM_SETFONT,hFont,TRUE);
944 DeleteObject(oldFont);
947 break;
949 case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
950 if (i!=CB_ERR)
952 lpcf->rgbColors=textcolors[i];
953 InvalidateRect( GetDlgItem(hDlg,stc6), NULL, 0 );
955 break;
957 case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
958 if (lpcf->hwndOwner)
959 SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
960 /* if (CFn_HookCallChk(lpcf))
961 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
962 break;
964 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
965 ( (lpcf->Flags & CF_LIMITSIZE) &&
966 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
967 (-lpxx->lfHeight <= lpcf->nSizeMax)))
968 EndDialog(hDlg, TRUE);
969 else
971 char buffer[80];
972 sprintf(buffer,"Select a font size between %d and %d points.",
973 lpcf->nSizeMin,lpcf->nSizeMax);
974 MessageBoxA(hDlg, buffer, NULL, MB_OK);
976 return(TRUE);
977 case IDCANCEL:EndDialog(hDlg, FALSE);
978 return(TRUE);
980 return(FALSE);
983 static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
985 DeleteObject(SendDlgItemMessageA(hwnd, stc6, WM_GETFONT, 0, 0));
986 return TRUE;
990 /***********************************************************************
991 * FormatCharDlgProc16 (COMMDLG.16)
992 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
993 2. some CF_.. flags are not supported
994 3. some TType extensions
996 LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
997 LPARAM lParam)
999 LPCHOOSEFONT16 lpcf;
1000 LPCHOOSEFONTA lpcf32a;
1001 LRESULT res=0;
1002 if (message!=WM_INITDIALOG)
1004 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
1005 if (!lpcf)
1006 return FALSE;
1007 if (CFn_HookCallChk(lpcf))
1008 res=CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,message,wParam,lParam);
1009 if (res)
1010 return res;
1012 else
1014 lpcf=(LPCHOOSEFONT16)lParam;
1015 lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
1016 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
1018 TRACE("CFn_WMInitDialog returned FALSE\n");
1019 return FALSE;
1021 if (CFn_HookCallChk(lpcf))
1022 return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1024 lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
1025 switch (message)
1027 case WM_MEASUREITEM:
1029 MEASUREITEMSTRUCT16* mis16 = MapSL(lParam);
1030 MEASUREITEMSTRUCT mis;
1031 mis.CtlType = mis16->CtlType;
1032 mis.CtlID = mis16->CtlID;
1033 mis.itemID = mis16->itemID;
1034 mis.itemWidth = mis16->itemWidth;
1035 mis.itemHeight = mis16->itemHeight;
1036 mis.itemData = mis16->itemData;
1037 res = CFn_WMMeasureItem(hDlg, wParam, (LPARAM)&mis);
1038 mis16->itemWidth = (UINT16)mis.itemWidth;
1039 mis16->itemHeight = (UINT16)mis.itemHeight;
1041 break;
1042 case WM_DRAWITEM:
1044 DRAWITEMSTRUCT16* dis16 = MapSL(lParam);
1045 DRAWITEMSTRUCT dis;
1046 dis.CtlType = dis16->CtlType;
1047 dis.CtlID = dis16->CtlID;
1048 dis.itemID = dis16->itemID;
1049 dis.itemAction = dis16->itemAction;
1050 dis.itemState = dis16->itemState;
1051 dis.hwndItem = dis16->hwndItem;
1052 dis.hDC = dis16->hDC;
1053 dis.itemData = dis16->itemData;
1054 CONV_RECT16TO32( &dis16->rcItem, &dis.rcItem );
1055 res = CFn_WMDrawItem(hDlg, wParam, (LPARAM)&dis);
1057 break;
1058 case WM_CTLCOLOR:
1059 if (HIWORD(lParam) == CTLCOLOR_STATIC)
1060 res=CFn_WMCtlColorStatic(hDlg, (HDC)wParam, (HWND)LOWORD(lParam), lpcf32a);
1061 break;
1062 case WM_COMMAND:
1063 res=CFn_WMCommand(hDlg, MAKEWPARAM( wParam, HIWORD(lParam) ), LOWORD(lParam), lpcf32a);
1064 break;
1065 case WM_DESTROY:
1066 res=CFn_WMDestroy(hDlg, wParam, lParam);
1067 break;
1068 case WM_CHOOSEFONT_GETLOGFONT:
1069 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
1070 FIXME("current logfont back to caller\n");
1071 break;
1073 return res;
1076 /***********************************************************************
1077 * FormatCharDlgProcA [internal]
1079 LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
1080 LPARAM lParam)
1082 LPCHOOSEFONTA lpcf;
1083 LRESULT res=FALSE;
1084 if (uMsg!=WM_INITDIALOG)
1086 lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
1087 if (!lpcf)
1088 return FALSE;
1089 if (CFn_HookCallChk32(lpcf))
1090 res=CallWindowProcA((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
1091 if (res)
1092 return res;
1094 else
1096 lpcf=(LPCHOOSEFONTA)lParam;
1097 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
1099 TRACE("CFn_WMInitDialog returned FALSE\n");
1100 return FALSE;
1102 if (CFn_HookCallChk32(lpcf))
1103 return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1105 switch (uMsg)
1107 case WM_MEASUREITEM:
1108 return CFn_WMMeasureItem(hDlg, wParam, lParam);
1109 case WM_DRAWITEM:
1110 return CFn_WMDrawItem(hDlg, wParam, lParam);
1111 case WM_CTLCOLORSTATIC:
1112 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
1113 case WM_COMMAND:
1114 return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
1115 case WM_DESTROY:
1116 return CFn_WMDestroy(hDlg, wParam, lParam);
1117 case WM_CHOOSEFONT_GETLOGFONT:
1118 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1119 lParam);
1120 FIXME("current logfont back to caller\n");
1121 break;
1123 return res;
1126 /***********************************************************************
1127 * FormatCharDlgProcW [internal]
1129 LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
1130 LPARAM lParam)
1132 LPCHOOSEFONTW lpcf32w;
1133 LPCHOOSEFONTA lpcf32a;
1134 LRESULT res=FALSE;
1135 if (uMsg!=WM_INITDIALOG)
1137 lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
1138 if (!lpcf32w)
1139 return FALSE;
1140 if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
1141 res=CallWindowProcW((WNDPROC)lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
1142 if (res)
1143 return res;
1145 else
1147 lpcf32w=(LPCHOOSEFONTW)lParam;
1148 lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
1149 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
1151 TRACE("CFn_WMInitDialog returned FALSE\n");
1152 return FALSE;
1154 if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
1155 return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1157 lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
1158 switch (uMsg)
1160 case WM_MEASUREITEM:
1161 return CFn_WMMeasureItem(hDlg, wParam, lParam);
1162 case WM_DRAWITEM:
1163 return CFn_WMDrawItem(hDlg, wParam, lParam);
1164 case WM_CTLCOLORSTATIC:
1165 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
1166 case WM_COMMAND:
1167 return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
1168 case WM_DESTROY:
1169 return CFn_WMDestroy(hDlg, wParam, lParam);
1170 case WM_CHOOSEFONT_GETLOGFONT:
1171 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1172 lParam);
1173 FIXME("current logfont back to caller\n");
1174 break;
1176 return res;