[1/2] comctl32: Implement PSM_SETHEADERTITLE[AW] (try 2)

André Hentschel nerv at dawncrow.de
Wed Dec 28 09:10:03 CST 2011


improved string handling as in CreatePropertySheetPage, therefor i moved load_string to avoid forward declaration
---
 dlls/comctl32/propsheet.c |   91 +++++++++++++++++++++++++-------------------
 1 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index e6d2d30..f7a16a3 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -35,7 +35,6 @@
  *     o PSM_INSERTPAGE
  *     o PSM_RECALCPAGESIZES
  *     o PSM_SETHEADERSUBTITLE
- *     o PSM_SETHEADERTITLE
  *     o WM_HELP
  *     o WM_CONTEXTMENU
  *   - Notifications:
@@ -177,6 +176,41 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 WINE_DEFAULT_DEBUG_CHANNEL(propsheet);
 
+static LPWSTR load_string( HINSTANCE instance, LPCWSTR str )
+{
+    LPWSTR ret;
+
+    if (IS_INTRESOURCE(str))
+    {
+        HRSRC hrsrc;
+        HGLOBAL hmem;
+        WCHAR *ptr;
+        WORD i, id = LOWORD(str);
+        UINT len;
+
+        if (!(hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((id >> 4) + 1), (LPWSTR)RT_STRING )))
+            return NULL;
+        if (!(hmem = LoadResource( instance, hrsrc ))) return NULL;
+        if (!(ptr = LockResource( hmem ))) return NULL;
+        for (i = id & 0x0f; i > 0; i--) ptr += *ptr + 1;
+        len = *ptr;
+        if (!len) return NULL;
+        ret = Alloc( (len + 1) * sizeof(WCHAR) );
+        if (ret)
+        {
+            memcpy( ret, ptr + 1, len * sizeof(WCHAR) );
+            ret[len] = 0;
+        }
+    }
+    else
+    {
+        int len = (strlenW(str) + 1) * sizeof(WCHAR);
+        ret = Alloc( len );
+        if (ret) memcpy( ret, str, len );
+    }
+    return ret;
+}
+
 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
 /******************************************************************************
  *            PROPSHEET_UnImplementedFlags
@@ -2491,7 +2525,13 @@ static BOOL PROPSHEET_InsertPage(HWND hwndDlg, HPROPSHEETPAGE hpageInsertAfter,
  */
 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg, int iPageIndex, LPCWSTR pszHeaderTitle)
 {
-    FIXME("(%p, %d, %s): stub\n", hwndDlg, iPageIndex, debugstr_w(pszHeaderTitle));
+    PropSheetInfo * psInfo = GetPropW(hwndDlg, PropSheetInfoStr);
+    LPPROPSHEETPAGEW ppshpage = (LPPROPSHEETPAGEW)psInfo->proppage[iPageIndex].hpage;
+
+    TRACE("(%p, %d, %s)\n", hwndDlg, iPageIndex, debugstr_w(pszHeaderTitle));
+
+    ppshpage->pszHeaderTitle = load_string( ppshpage->hInstance, pszHeaderTitle );
+    ppshpage->dwFlags |= PSP_USEHEADERTITLE;
 }
 
 /******************************************************************************
@@ -2499,7 +2539,16 @@ static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg, int iPageIndex, LPCWSTR pszH
  */
 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg, int iPageIndex, LPCSTR pszHeaderTitle)
 {
-    FIXME("(%p, %d, %s): stub\n", hwndDlg, iPageIndex, debugstr_a(pszHeaderTitle));
+    PropSheetInfo * psInfo = GetPropW(hwndDlg, PropSheetInfoStr);
+    LPPROPSHEETPAGEW ppshpage = (LPPROPSHEETPAGEW)psInfo->proppage[iPageIndex].hpage;
+
+    TRACE("(%p, %d, %s)\n", hwndDlg, iPageIndex, debugstr_a(pszHeaderTitle));
+
+    if (!IS_INTRESOURCE( pszHeaderTitle ))
+        PROPSHEET_AtoW(&ppshpage->pszHeaderTitle, pszHeaderTitle);
+    else
+        ppshpage->pszHeaderTitle = load_string( ppshpage->hInstance, (LPCWSTR)pszHeaderTitle );
+    ppshpage->dwFlags |= PSP_USEHEADERTITLE;
 }
 
 /******************************************************************************
@@ -2868,42 +2917,6 @@ INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
   return PROPSHEET_PropertySheet(psInfo, TRUE);
 }
 
-static LPWSTR load_string( HINSTANCE instance, LPCWSTR str )
-{
-    LPWSTR ret;
-
-    if (IS_INTRESOURCE(str))
-    {
-        HRSRC hrsrc;
-        HGLOBAL hmem;
-        WCHAR *ptr;
-        WORD i, id = LOWORD(str);
-        UINT len;
-
-        if (!(hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((id >> 4) + 1), (LPWSTR)RT_STRING )))
-            return NULL;
-        if (!(hmem = LoadResource( instance, hrsrc ))) return NULL;
-        if (!(ptr = LockResource( hmem ))) return NULL;
-        for (i = id & 0x0f; i > 0; i--) ptr += *ptr + 1;
-        len = *ptr;
-        if (!len) return NULL;
-        ret = Alloc( (len + 1) * sizeof(WCHAR) );
-        if (ret)
-        {
-            memcpy( ret, ptr + 1, len * sizeof(WCHAR) );
-            ret[len] = 0;
-        }
-    }
-    else
-    {
-        int len = (strlenW(str) + 1) * sizeof(WCHAR);
-        ret = Alloc( len );
-        if (ret) memcpy( ret, str, len );
-    }
-    return ret;
-}
-
-
 /******************************************************************************
  *            CreatePropertySheetPage    (COMCTL32.@)
  *            CreatePropertySheetPageA   (COMCTL32.@)
-- 

Best Regards, André Hentschel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Nachrichtenteil als Anhang
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20111228/8ed865ce/attachment.ksh>


More information about the wine-patches mailing list