Alexandre Julliard : user32: Move loading of static icons for 16-bit windows to the 16-bit wrapper.

Alexandre Julliard julliard at winehq.org
Tue Dec 29 09:06:39 CST 2009


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Dec 28 19:53:12 2009 +0100

user32: Move loading of static icons for 16-bit windows to the 16-bit wrapper.

---

 dlls/user.exe16/message.c |   27 +++++++++++
 dlls/user32/static.c      |  113 ++++++++++++++++----------------------------
 2 files changed, 68 insertions(+), 72 deletions(-)

diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c
index b8a5190..7dccc5f 100644
--- a/dlls/user.exe16/message.c
+++ b/dlls/user.exe16/message.c
@@ -2594,6 +2594,33 @@ static LRESULT static_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
 {
     switch (msg)
     {
+    case WM_NCCREATE:
+    {
+        CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
+        LRESULT ret = wow_handlers32.static_proc( hwnd, msg, wParam, lParam, unicode );
+
+        if (!ret) return 0;
+        if (((ULONG_PTR)cs->hInstance >> 16)) return ret;  /* 32-bit instance, nothing to do */
+        switch (cs->style & SS_TYPEMASK)
+        {
+        case SS_ICON:
+            {
+                HICON16 icon = LoadIcon16( HINSTANCE_16(cs->hInstance), cs->lpszName );
+                if (!icon) icon = LoadCursor16( HINSTANCE_16(cs->hInstance), cs->lpszName );
+                if (icon) wow_handlers32.static_proc( hwnd, STM_SETIMAGE, IMAGE_ICON,
+                                                      (LPARAM)HICON_32(icon), FALSE );
+                break;
+            }
+        case SS_BITMAP:
+            {
+                HBITMAP16 bitmap = LoadBitmap16( HINSTANCE_16(cs->hInstance), cs->lpszName );
+                if (bitmap) wow_handlers32.static_proc( hwnd, STM_SETIMAGE, IMAGE_BITMAP,
+                                                        (LPARAM)HBITMAP_32(bitmap), FALSE );
+                break;
+            }
+        }
+        return ret;
+    }
     case STM_SETICON16:
         wParam = (WPARAM)HICON_32( (HICON16)wParam );
         return wow_handlers32.static_proc( hwnd, STM_SETICON, wParam, lParam, FALSE );
diff --git a/dlls/user32/static.c b/dlls/user32/static.c
index 2ed3b75..5386c84 100644
--- a/dlls/user32/static.c
+++ b/dlls/user32/static.c
@@ -256,23 +256,25 @@ static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
  *
  * Load the icon for an SS_ICON control.
  */
-static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
+static HICON STATIC_LoadIconA( HINSTANCE hInstance, LPCSTR name, DWORD style )
 {
-    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    if ((style & SS_REALSIZEIMAGE) != 0)
-    {
-        return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
-    }
-    else
+    HICON hicon;
+
+    if (hInstance && ((ULONG_PTR)hInstance >> 16))
     {
-        HICON hicon = LoadIconA( hInstance, name );
-        if (!hicon) hicon = LoadCursorA( hInstance, name );
-        if (!hicon) hicon = LoadIconA( 0, name );
-        /* Windows doesn't try to load a standard cursor,
-           probably because most IDs for standard cursors conflict
-           with the IDs for standard icons anyway */
-        return hicon;
+        if ((style & SS_REALSIZEIMAGE) != 0)
+            hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+        else
+        {
+            hicon = LoadIconA( hInstance, name );
+            if (!hicon) hicon = LoadCursorA( hInstance, name );
+        }
     }
+    if (!hicon) hicon = LoadIconA( 0, name );
+    /* Windows doesn't try to load a standard cursor,
+       probably because most IDs for standard cursors conflict
+       with the IDs for standard icons anyway */
+    return hicon;
 }
 
 /***********************************************************************
@@ -280,47 +282,25 @@ static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
  *
  * Load the icon for an SS_ICON control.
  */
-static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
+static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
 {
-    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    if ((style & SS_REALSIZEIMAGE) != 0)
-    {
-        return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
-    }
-    else
+    HICON hicon;
+
+    if (hInstance && ((ULONG_PTR)hInstance >> 16))
     {
-        HICON hicon = LoadIconW( hInstance, name );
-        if (!hicon) hicon = LoadCursorW( hInstance, name );
-        if (!hicon) hicon = LoadIconW( 0, name );
-        /* Windows doesn't try to load a standard cursor,
-           probably because most IDs for standard cursors conflict
-           with the IDs for standard icons anyway */
-        return hicon;
+        if ((style & SS_REALSIZEIMAGE) != 0)
+            hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+        else
+        {
+            hicon = LoadIconW( hInstance, name );
+            if (!hicon) hicon = LoadCursorW( hInstance, name );
+        }
     }
-}
-
-/***********************************************************************
- *           STATIC_LoadBitmapA
- *
- * Load the bitmap for an SS_BITMAP control.
- */
-static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
-{
-    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
-    return LoadBitmapA( hInstance, name );
-}
-
-/***********************************************************************
- *           STATIC_LoadBitmapW
- *
- * Load the bitmap for an SS_BITMAP control.
- */
-static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
-{
-    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
-    return LoadBitmapW( hInstance, name );
+    if (!hicon) hicon = LoadIconW( 0, name );
+    /* Windows doesn't try to load a standard cursor,
+       probably because most IDs for standard cursors conflict
+       with the IDs for standard icons anyway */
+    return hicon;
 }
 
 /***********************************************************************
@@ -471,42 +451,31 @@ LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
 
     case WM_NCCREATE:
         {
-            LPCSTR textA;
-            LPCWSTR textW;
-    
+            CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
+
             if (full_style & SS_SUNKEN)
                 SetWindowLongW( hwnd, GWL_EXSTYLE,
                                 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
 
-            if(unicode)
-            {
-                textA = NULL;
-                textW = ((LPCREATESTRUCTW)lParam)->lpszName;
-            }
-            else
-            {
-                textA = ((LPCREATESTRUCTA)lParam)->lpszName;
-                textW = NULL;
-            }
-
             switch (style) {
             case SS_ICON:
                 {
                     HICON hIcon;
-                    if(unicode)
-                       hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
+                    if (unicode || IS_INTRESOURCE(cs->lpszName))
+                       hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style);
                     else
-                       hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
+                       hIcon = STATIC_LoadIconA(cs->hInstance, (LPCSTR)cs->lpszName, full_style);
                     STATIC_SetIcon(hwnd, hIcon, full_style);
                 }
                 break;
             case SS_BITMAP:
+                if ((ULONG_PTR)cs->hInstance >> 16)
                 {
                     HBITMAP hBitmap;
-                    if(unicode)
-                        hBitmap = STATIC_LoadBitmapW(hwnd, textW);
+                    if (unicode || IS_INTRESOURCE(cs->lpszName))
+                        hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName);
                     else
-                        hBitmap = STATIC_LoadBitmapA(hwnd, textA);
+                        hBitmap = LoadBitmapA(cs->hInstance, (LPCSTR)cs->lpszName);
                     STATIC_SetBitmap(hwnd, hBitmap, full_style);
                 }
                 break;




More information about the wine-cvs mailing list