Static control [04/10]: Support SS_REALSIZEIMAGE

Michael Kaufmann hallo at michael-kaufmann.ch
Wed Jan 11 16:24:59 CST 2006


Changelog:
  - Support SS_REALSIZEIMAGE (this flag means "it's not necessary to 
load icons in the default icon size")
  - SS_ICON: Ability to display cursors
-------------- next part --------------
--- static-old.c	2006-01-11 22:37:16.000000000 +0100
+++ static.c	2006-01-11 22:40:08.000000000 +0100
@@ -29,7 +29,6 @@
  * TODO:
  *
  *   Styles
- *   - SS_REALSIZECONTROL
  *   - SS_RIGHTJUST
  *
  *   Notifications
@@ -206,12 +205,23 @@
  *
  * Load the icon for an SS_ICON control.
  */
-static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name )
+static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
 {
     HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    HICON hicon = LoadIconA( hInstance, name );
-    if (!hicon) hicon = LoadIconA( 0, name );
-    return hicon;
+    if ((style & SS_REALSIZEIMAGE) != 0)
+    {
+        return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+    }
+    else
+    {
+        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;
+    }
 }
 
 /***********************************************************************
@@ -219,12 +229,23 @@
  *
  * Load the icon for an SS_ICON control.
  */
-static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name )
+static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
 {
     HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
-    HICON hicon = LoadIconW( hInstance, name );
-    if (!hicon) hicon = LoadIconW( 0, name );
-    return hicon;
+    if ((style & SS_REALSIZEIMAGE) != 0)
+    {
+        return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+    }
+    else
+    {
+        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;
+    }
 }
 
 /***********************************************************************
@@ -368,9 +389,9 @@
 	{
 	    HICON hIcon;
 	    if(unicode)
-		hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam);
+		hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam, full_style);
 	    else
-		hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
+		hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam, full_style);
             /* FIXME : should we also return the previous hIcon here ??? */
             STATIC_SetIcon(hwnd, hIcon, full_style);
 	    break;


More information about the wine-patches mailing list