Piotr Caban : oleaut32: Set dialog size in dialog box units in OleCreatePropertyFrame.

Alexandre Julliard julliard at winehq.org
Mon Sep 27 11:29:39 CDT 2010


Module: wine
Branch: master
Commit: f4ef2d6e027a90f3209adc991d97230266eb7dec
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f4ef2d6e027a90f3209adc991d97230266eb7dec

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Mon Sep 27 12:03:08 2010 +0200

oleaut32: Set dialog size in dialog box units in OleCreatePropertyFrame.

---

 dlls/oleaut32/olepropframe.c |   55 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/dlls/oleaut32/olepropframe.c b/dlls/oleaut32/olepropframe.c
index 1a82290..7acf4e9 100644
--- a/dlls/oleaut32/olepropframe.c
+++ b/dlls/oleaut32/olepropframe.c
@@ -150,6 +150,8 @@ IPropertyPageSiteVtbl PropertyPageSiteVtbl = {
  */
 HRESULT WINAPI OleCreatePropertyFrameIndirect(LPOCPFIPARAMS lpParams)
 {
+    static const WCHAR comctlW[] = { 'c','o','m','c','t','l','3','2','.','d','l','l',0 };
+
     PROPSHEETHEADERW property_sheet;
     PROPSHEETPAGEW property_sheet_page;
     struct {
@@ -162,6 +164,14 @@ HRESULT WINAPI OleCreatePropertyFrameIndirect(LPOCPFIPARAMS lpParams)
     IPropertyPageSite *property_page_site;
     HRESULT res;
     int i;
+    HMODULE hcomctl;
+    HRSRC property_sheet_dialog_find = NULL;
+    HGLOBAL property_sheet_dialog_load = NULL;
+    WCHAR *property_sheet_dialog_data = NULL;
+    HDC hdc;
+    LOGFONTW font_desc;
+    HFONT hfont;
+    LONG font_width = 4, font_height = 8;
 
     if(!lpParams)
         return E_POINTER;
@@ -183,6 +193,47 @@ HRESULT WINAPI OleCreatePropertyFrameIndirect(LPOCPFIPARAMS lpParams)
     if(lpParams->dispidInitialProperty)
         FIXME("dispidInitialProperty not yet implemented\n");
 
+    hdc = GetDC(NULL);
+    hcomctl = LoadLibraryW(comctlW);
+    if(hcomctl)
+        property_sheet_dialog_find = FindResourceW(hcomctl,
+                MAKEINTRESOURCEW(1006 /*IDD_PROPSHEET*/), (LPWSTR)RT_DIALOG);
+    if(property_sheet_dialog_find)
+        property_sheet_dialog_load = LoadResource(hcomctl, property_sheet_dialog_find);
+    if(property_sheet_dialog_load)
+        property_sheet_dialog_data = LockResource(property_sheet_dialog_load);
+
+    if(property_sheet_dialog_data) {
+        if(property_sheet_dialog_data[1] == 0xffff) {
+            ERR("Expected DLGTEMPLATE structure\n");
+            return E_OUTOFMEMORY;
+        }
+
+        property_sheet_dialog_data += sizeof(DLGTEMPLATE)/sizeof(WCHAR);
+        /* Skip menu, class and title */
+        property_sheet_dialog_data += lstrlenW(property_sheet_dialog_data)+1;
+        property_sheet_dialog_data += lstrlenW(property_sheet_dialog_data)+1;
+        property_sheet_dialog_data += lstrlenW(property_sheet_dialog_data)+1;
+
+        memset(&font_desc, 0, sizeof(LOGFONTW));
+        /* Calculate logical height */
+        font_desc.lfHeight = -MulDiv(property_sheet_dialog_data[0],
+                GetDeviceCaps(hdc, LOGPIXELSY), 72);
+        font_desc.lfCharSet = DEFAULT_CHARSET;
+        memcpy(font_desc.lfFaceName, property_sheet_dialog_data+1,
+                sizeof(WCHAR*)*(lstrlenW(property_sheet_dialog_data+1)+1));
+        hfont = CreateFontIndirectW(&font_desc);
+
+        if(hfont) {
+            hfont = SelectObject(hdc, hfont);
+            font_width = GdiGetCharDimensions(hdc, NULL, &font_height);
+            SelectObject(hdc, hfont);
+        }
+    }
+    if(hcomctl)
+        FreeLibrary(hcomctl);
+    ReleaseDC(NULL, hdc);
+
     memset(&property_sheet, 0, sizeof(property_sheet));
     property_sheet.dwSize = sizeof(property_sheet);
     if(lpParams->lpszCaption) {
@@ -237,8 +288,8 @@ HRESULT WINAPI OleCreatePropertyFrameIndirect(LPOCPFIPARAMS lpParams)
         if(FAILED(res))
             continue;
 
-        dialogs[i].template.cx = page_info.size.cx;
-        dialogs[i].template.cy = page_info.size.cy;
+        dialogs[i].template.cx = MulDiv(page_info.size.cx, 4, font_width);
+        dialogs[i].template.cy = MulDiv(page_info.size.cy, 8, font_height);
 
         property_sheet_page.u.pResource = &dialogs[i].template;
         property_sheet_page.lParam = (LPARAM)property_page[i];




More information about the wine-cvs mailing list