Sync to Wine-0_9_2:
Rein Klazes <wijn@wanadoo.nl>
- Fixes for FormatCharDlgProc16:
- properly store the ChooseFont pointer, use a window property as the
  A and W functions do;
- handle other messages then WM_INITDIALOG and WM_MEASUREITEM as well.
- In CFn_CHOOSEFONT16to32W fix the conversion of the lpTemplateName and
  the lpszStyle fields.
Francois Gouget <fgouget@free.fr>
- Remove spaces before '\n' in traces.
Dmitry Timoshkov <dmitry@codeweavers.com>
- There is no need to resize our own fake dialog to match the parent, it
  doesn't have controls anyway.
Markus Amsler <markus.amsler@oribi.org>
- Improve c2man Documented-Total count. Changes:
- add missing description
- complete missing A/W pairs
- document remaining comdlg32 functions
Modified: trunk/reactos/lib/comdlg32/cdlg_Ko.rc
Modified: trunk/reactos/lib/comdlg32/filedlg.c
Modified: trunk/reactos/lib/comdlg32/fontdlg16.c

Modified: trunk/reactos/lib/comdlg32/cdlg_Ko.rc
--- trunk/reactos/lib/comdlg32/cdlg_Ko.rc	2005-11-26 10:17:32 UTC (rev 19621)
+++ trunk/reactos/lib/comdlg32/cdlg_Ko.rc	2005-11-26 10:18:02 UTC (rev 19622)
@@ -1,5 +1,6 @@
 /*
  * Copyright 1996 Bang Jun Young
+ * Copyright 2005 YunSong Hwang
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -85,7 +86,7 @@
  LTEXT "???Ô Ã??·(&Q):", 1092, 6, 100, 76, 9
  COMBOBOX 1136, 80, 100, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
  CHECKBOX "ã??¤À? ???Ô(&L)", 1040, 20, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Condensed", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX " ã°?? ????", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
 }
 
 
@@ -117,76 +118,76 @@
 PRINT32 DIALOG LOADONCALL MOVEABLE DISCARDABLE  32, 32, 288, 186
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
-CAPTION "Print"
+CAPTION "???Ô"
 FONT 9, "MS Shell Dlg"
 {
-    DEFPUSHBUTTON   "OK",     IDOK,     180,164, 48,14, WS_GROUP | BS_DEFPUSHBUTTON
-    PUSHBUTTON      "Cancel", IDCANCEL, 232,164, 48,14, WS_GROUP
-    PUSHBUTTON      "&Help",  pshHelp,  50, 161, 48,14, WS_GROUP
+    DEFPUSHBUTTON   "?«??",     IDOK,     180,164, 48,14, WS_GROUP | BS_DEFPUSHBUTTON
+    PUSHBUTTON      "?Ù?Ê", IDCANCEL, 232,164, 48,14, WS_GROUP
+    PUSHBUTTON      "ÁÁ??©?(&H)",  pshHelp,  50, 161, 48,14, WS_GROUP
 
-    GROUPBOX        "Printer",        grp4,   8,  4, 272,84, WS_GROUP
-    CONTROL         "Print to fi&le", chx1, "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,212,70,64,12
-    PUSHBUTTON      "&Properties",    psh2, 212, 17,  60,14, WS_GROUP
-    LTEXT           "&Name:",         stc6,  16, 20,  36,8
+    GROUPBOX        "Ã?©???",        grp4,   8,  4, 272,84, WS_GROUP
+    CONTROL         "ã??¤À? ???Ô(&l)", chx1, "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,212,70,64,12
+    PUSHBUTTON      "?Ë??(&P)",    psh2, 212, 17,  60,14, WS_GROUP
+    LTEXT           "??©º(&N):",         stc6,  16, 20,  36,8
     COMBOBOX                          cmb4,  52, 18, 152,152,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
-    LTEXT           "Status:",        stc8,  16, 36,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy State",    stc12, 52, 36, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Type:",          stc7,  16, 48,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Type",     stc11, 52, 48, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Where:",         stc10, 16, 60,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Location", stc14, 52, 60, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Comment:",       stc9,  16, 72,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Remark",   stc13, 52, 72, 152,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "?¾??:",        stc8,  16, 36,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ?¾??",    stc12, 52, 36, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "?©?È:",          stc7,  16, 48,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ?©?È",     stc11, 52, 48, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "¥¯Á­?:",         stc10, 16, 60,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ?º?í", stc14, 52, 60, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "??©Ý:",       stc9,  16, 72,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ??©Ý",   stc13, 52, 72, 152,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
 
-    GROUPBOX        "Copies",         grp2, 160, 92, 120,64, WS_GROUP
-    LTEXT           "Number of &copies:",stc5,168,108,68,8
+    GROUPBOX        "???þ??",         grp2, 160, 92, 120,64, WS_GROUP
+    LTEXT           "???þ?? ???÷(&c):",stc5,168,108,68,8
     ICON            "",               ico3, 162,124,  76,24, WS_GROUP | SS_CENTERIMAGE
-    CONTROL         "C&ollate",       chx2,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,240,130,36,12
+    CONTROL         "Ãi?í?Ô(&o)",       chx2,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,240,130,36,12
     EDITTEXT                          edt3, 240,106,  32,12, WS_GROUP | ES_NUMBER
 
-    GROUPBOX        "Print range",    grp1,   8,92,  144,64, WS_GROUP
-    CONTROL         "&All",           rad1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,106,64,12
-    CONTROL         "Pa&ges",         rad3,"Button",BS_AUTORADIOBUTTON,16,122,36,12
-    CONTROL         "&Selection",     rad2,"Button",BS_AUTORADIOBUTTON,16,138,64,12
+    GROUPBOX        "???Ô ?³?º",    grp1,   8,92,  144,64, WS_GROUP
+    CONTROL         "©­Á?(&A)",           rad1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,106,64,12
+    CONTROL         "ãõ???÷(&g)",         rad3,"Button",BS_AUTORADIOBUTTON,16,122,36,12
+    CONTROL         "?????Á?¬(&S)",     rad2,"Button",BS_AUTORADIOBUTTON,16,138,64,12
     EDITTEXT                          edt1,  74,122,  26,12, WS_GROUP | ES_NUMBER
     EDITTEXT                          edt2, 118,122,  26,12, WS_GROUP | ES_NUMBER
-    RTEXT           "&from:",         stc2,  52,124,  20,8
-    RTEXT           "&to:",           stc3, 100,124,  16,8
+    RTEXT           "?®?Ô?¡????(&f):",         stc2,  52,124,  20,8
+    RTEXT           "?®?Ô?¯?÷(&t):",           stc3, 100,124,  16,8
 }
 
 PRINT32_SETUP DIALOG LOADONCALL MOVEABLE DISCARDABLE  32, 32, 288, 178
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
-CAPTION "Print Setup"
+CAPTION "???Ô ???ñ"
 FONT 9, "MS Shell Dlg"
 BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,180,156,48,14,WS_GROUP
-    PUSHBUTTON      "Cancel",IDCANCEL,232,156,48,14
-/*    PUSHBUTTON      "Network...", psh5, 284,156,48,14 */
+    DEFPUSHBUTTON   "?«??",IDOK,180,156,48,14,WS_GROUP
+    PUSHBUTTON      "?Ù?Ê",IDCANCEL,232,156,48,14
+/*    PUSHBUTTON      "?Îã«?÷?®...", psh5, 284,156,48,14 */
 
-    GROUPBOX        "Printer",        grp4,   8,  4, 272,84, WS_GROUP
-    PUSHBUTTON      "&Properties",    psh2, 212, 17,  60,14, WS_GROUP
-    LTEXT           "&Name:",         stc6,  16, 20,  36,8
+    GROUPBOX        "Ã?©???",        grp4,   8,  4, 272,84, WS_GROUP
+    PUSHBUTTON      "?Ë??(&P)",    psh2, 212, 17,  60,14, WS_GROUP
+    LTEXT           "??©º(&N):",         stc6,  16, 20,  36,8
     COMBOBOX                          cmb1,  52, 18, 152,152,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
-    LTEXT           "Status:",        stc8,  16, 36,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy State",    stc12, 52, 36, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Type:",          stc7,  16, 48,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Type",     stc11, 52, 48, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Where:",         stc10, 16, 60,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Location", stc14, 52, 60, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
-    LTEXT           "Comment:",       stc9,  16, 72,  36,10, SS_NOPREFIX
-    LTEXT           "Dummy Remark",   stc13, 52, 72, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "?¾??:",        stc8,  16, 36,  36,10, SS_NOPREFIX
+    LTEXT           "?§?± ?¾??",    stc12, 52, 36, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "?©?È:",          stc7,  16, 48,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ?©?È",     stc11, 52, 48, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "¥¯Á­?:",         stc10, 16, 60,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ?º?í", stc14, 52, 60, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
+    LTEXT           "??©Ý:",       stc9,  16, 72,  36,10, SS_NOPREFIX
+    LTEXT           "?§?? ??©Ý",   stc13, 52, 72, 224,10, SS_NOPREFIX | SS_LEFTNOWORDWRAP
 
-    GROUPBOX        "Paper",          grp2,   8, 92, 164,56, WS_GROUP
-    LTEXT           "Si&ze:",         stc2,  16,108,  36, 8
+    GROUPBOX        "?¥??",          grp2,   8, 92, 164,56, WS_GROUP
+    LTEXT           "?®?Ô(&z):",         stc2,  16,108,  36, 8
     COMBOBOX                          cmb2,  52,106, 112,112,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
-    LTEXT           "&Source:",       stc3,  16,128,  36, 8
+    LTEXT           "?°??(&S):",       stc3,  16,128,  36, 8
     COMBOBOX                          cmb3,  52,126, 112,112,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
 
-    GROUPBOX        "Orientation",    grp1, 180, 92, 100,56, WS_GROUP
+    GROUPBOX        "?µÃÔ",    grp1, 180, 92, 100,56, WS_GROUP
     ICON            "",               ico1, 195,112,  18,20, WS_GROUP
-    CONTROL         "P&ortrait",      rad1,"Button",BS_AUTORADIOBUTTON | WS_GROUP |WS_TABSTOP,224,106,52,12
-    CONTROL         "L&andscape",     rad2,"Button",BS_AUTORADIOBUTTON,224,126,52,12
+    CONTROL         "?íÀ?(&o)",      rad1,"Button",BS_AUTORADIOBUTTON | WS_GROUP |WS_TABSTOP,224,106,52,12
+    CONTROL         "??À?(&a)",     rad2,"Button",BS_AUTORADIOBUTTON,224,126,52,12
 END
 
 

Modified: trunk/reactos/lib/comdlg32/filedlg.c
--- trunk/reactos/lib/comdlg32/filedlg.c	2005-11-26 10:17:32 UTC (rev 19621)
+++ trunk/reactos/lib/comdlg32/filedlg.c	2005-11-26 10:18:02 UTC (rev 19622)
@@ -283,7 +283,7 @@
     }
 
     /* Some shell namespace extensions depend on COM being initialized. */
-    hr = CoInitialize(NULL);
+    hr = OleInitialize(NULL);
 
     lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
                                   (LPDLGTEMPLATEA) template,
@@ -291,7 +291,7 @@
                                   FileOpenDlgProc95,
                                   (LPARAM) fodInfos);
     if (SUCCEEDED(hr)) 
-        CoUninitialize();
+        OleUninitialize();
 
     /* Unable to create the dialog */
     if( lRes == -1)
@@ -701,10 +701,6 @@
     /* finally use fixed parent size */
     rectParent.bottom -= help_fixup;
 
-    /* save the size of the parent's client area */
-    rectChild.right = rectParent.right;
-    rectChild.bottom = rectParent.bottom;
-
     /* set the size of the parent dialog */
     AdjustWindowRectEx(&rectParent, GetWindowLongW(hwndParentDlg, GWL_STYLE),
                        FALSE, GetWindowLongW(hwndParentDlg, GWL_EXSTYLE));
@@ -713,10 +709,6 @@
                  rectParent.right - rectParent.left,
                  rectParent.bottom - rectParent.top,
                  SWP_NOMOVE | SWP_NOZORDER);
-
-    /* set the size of the child dialog */
-    SetWindowPos(hwndChildDlg, HWND_BOTTOM,
-                 0, 0, rectChild.right, rectChild.bottom, SWP_NOACTIVATE);
 }
 
 static INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -1032,9 +1024,29 @@
          FILEDLG95_InitControls(hwnd);
 
          if (fodInfos->DlgInfos.hwndCustomDlg)
+         {
+             RECT rc;
+             UINT flags = SWP_NOACTIVATE;
+
              ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
                  (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
 
+             /* resize the custom dialog to the parent size */
+             if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
+                 GetClientRect(hwnd, &rc);
+             else
+             {
+                 /* our own fake template is zero sized and doesn't have
+                  * children, so there is no need to resize it.
+                  * Picasa depends on it.
+                  */
+                 flags |= SWP_NOSIZE;
+                 SetRectEmpty(&rc);
+             }
+             SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
+                          0, 0, rc.right, rc.bottom, flags);
+         }
+
       	 FILEDLG95_FillControls(hwnd, wParam, lParam);
 
          SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
@@ -3782,6 +3794,8 @@
 {
     BOOL win16look = FALSE;
 
+    TRACE("flags %08lx\n", ofn->Flags);
+
     /* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
     if (ofn->Flags & OFN_FILEMUSTEXIST)
         ofn->Flags |= OFN_PATHMUSTEXIST;
@@ -3810,6 +3824,12 @@
 {
     BOOL win16look = FALSE;
 
+    TRACE("flags %08lx\n", ofn->Flags);
+
+    /* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
+    if (ofn->Flags & OFN_FILEMUSTEXIST)
+        ofn->Flags |= OFN_PATHMUSTEXIST;
+
     if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
         win16look = (ofn->Flags & OFN_EXPLORER) ? FALSE : TRUE;
 

Modified: trunk/reactos/lib/comdlg32/fontdlg16.c
--- trunk/reactos/lib/comdlg32/fontdlg16.c	2005-11-26 10:17:32 UTC (rev 19621)
+++ trunk/reactos/lib/comdlg32/fontdlg16.c	2005-11-26 10:18:02 UTC (rev 19622)
@@ -41,6 +41,9 @@
 #include "cdlg.h"
 #include "cdlg16.h"
 
+static const WCHAR strWineFontData16[] =
+                               {'_','_','W','I','N','E','_','F','O','N','T','D','L','G','D','A','T','A','1','6',0};
+
 static void FONT_LogFont16To32W( const LPLOGFONT16 font16, LPLOGFONTW font32 )
 {
     font32->lfHeight = font16->lfHeight;
@@ -58,7 +61,7 @@
     font32->lfPitchAndFamily = font16->lfPitchAndFamily;
     MultiByteToWideChar(CP_ACP, 0, font16->lfFaceName,
                         LF_FACESIZE, font32->lfFaceName, LF_FACESIZE);
-};
+}
 
 static void FONT_Metrics16To32W( const TEXTMETRIC16 *pm16,
                                  NEWTEXTMETRICEXW *pnm32w)
@@ -67,24 +70,23 @@
     /* NOTE: only the fields used by AddFontStyle() are filled in */
     pnm32w->ntmTm.tmHeight = pm16->tmHeight;
     pnm32w->ntmTm.tmExternalLeading = pm16->tmExternalLeading;
-};
+}
 
 static void CFn_CHOOSEFONT16to32W(LPCHOOSEFONT16 chf16, LPCHOOSEFONTW chf32w)
 {
   int len;
-  if(chf16->lpTemplateName)
+  if (chf16->Flags & CF_ENABLETEMPLATE)
   {
-    len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)chf16->lpTemplateName, -1, NULL, 0);
-    chf32w->lpTemplateName = HeapAlloc(GetProcessHeap(), 0,len*sizeof(WCHAR));
-    MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName),
-                        -1, (LPWSTR)chf32w->lpTemplateName, len);
+      len = MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpTemplateName), -1, NULL, 0);
+      chf32w->lpTemplateName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+      MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpTemplateName),
+                           -1, (LPWSTR)chf32w->lpTemplateName, len);
   }
-  if(chf16->lpszStyle)
+  if (chf16->Flags & CF_USESTYLE)
   {
-    len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)chf16->lpszStyle, -1, NULL, 0);
-    chf32w->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
-    MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName),
-                        -1, chf32w->lpszStyle, len);
+      len = MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpszStyle), -1, NULL, 0);
+      chf32w->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+      MultiByteToWideChar( CP_ACP, 0, MapSL(chf16->lpszStyle), -1, chf32w->lpszStyle, len);
   }
   chf32w->lStructSize=sizeof(CHOOSEFONTW);
   chf32w->hwndOwner=HWND_32(chf16->hwndOwner);
@@ -95,12 +97,11 @@
   chf32w->lCustData=chf16->lCustData;
   chf32w->lpfnHook=NULL;
   chf32w->hInstance=HINSTANCE_32(chf16->hInstance);
-  chf32w->lpszStyle=MapSL(chf16->lpszStyle);
   chf32w->nFontType=chf16->nFontType;
   chf32w->nSizeMax=chf16->nSizeMax;
   chf32w->nSizeMin=chf16->nSizeMin;
   FONT_LogFont16To32W(MapSL(chf16->lpLogFont), chf32w->lpLogFont);
-};
+}
 
 /***********************************************************************
  *                          CFn_HookCallChk                 [internal]
@@ -122,11 +123,13 @@
 {
   HWND hwnd=HWND_32(LOWORD(lParam));
   HWND hDlg=GetParent(hwnd);
-  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongPtrW(hDlg, DWLP_USER);
+  LPCHOOSEFONT16 lpcf;
   LOGFONT16 *lplf = MapSL( logfont );
   TEXTMETRIC16 *lpmtrx16 = MapSL(metrics);
   ENUMLOGFONTEXW elf32w;
   NEWTEXTMETRICEXW nmtrx32w;
+
+  lpcf = (LPCHOOSEFONT16)GetPropW(hDlg, strWineFontData16);
   FONT_LogFont16To32W(lplf, &(elf32w.elfLogFont));
   FONT_Metrics16To32W(lpmtrx16, &nmtrx32w);
   return AddFontFamily(&elf32w, &nmtrx32w, nFontType,
@@ -142,11 +145,13 @@
   HWND hcmb2=HWND_32(LOWORD(lParam));
   HWND hcmb3=HWND_32(HIWORD(lParam));
   HWND hDlg=GetParent(hcmb3);
-  LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongPtrW(hDlg, DWLP_USER);
+  LPCHOOSEFONT16 lpcf;
   LOGFONT16 *lplf = MapSL(logfont);
   TEXTMETRIC16 *lpmtrx16 = MapSL(metrics);
   ENUMLOGFONTEXW elf32w;
   NEWTEXTMETRICEXW nmtrx32w;
+
+  lpcf = (LPCHOOSEFONT16)GetPropW(hDlg, strWineFontData16);
   FONT_LogFont16To32W(lplf, &(elf32w.elfLogFont));
   FONT_Metrics16To32W(lpmtrx16, &nmtrx32w);
   return AddFontStyle(&elf32w, &nmtrx32w, nFontType,
@@ -300,13 +305,13 @@
   BOOL16 res=0;
   if (message!=WM_INITDIALOG)
   {
-   lpcf=(LPCHOOSEFONT16)GetWindowLongPtrW(hDlg, DWLP_USER);
-   if (!lpcf && message != WM_MEASUREITEM)
-      return FALSE;
-   if (CFn_HookCallChk(lpcf))
-     res=CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg16,message,wParam,lParam);
-   if (res)
-    return res;
+      lpcf = (LPCHOOSEFONT16)GetPropW(hDlg, strWineFontData16);
+      if (!lpcf)
+          return FALSE;
+      if (CFn_HookCallChk(lpcf))
+          res=CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg16,message,wParam,lParam);
+      if (res)
+          return res;
   }
   else
   {
@@ -316,6 +321,7 @@
       TRACE("CFn_WMInitDialog returned FALSE\n");
       return FALSE;
     }
+    SetPropW(hDlg, strWineFontData16, (HANDLE)lParam);
     if (CFn_HookCallChk(lpcf))
       return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg16,WM_INITDIALOG,wParam,lParam);
   }