Static control [03/10]: Support SS_REALSIZECONTROL

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


Changelog:
  - Support SS_REALSIZECONTROL (this flag means "don't resize the 
control to the size of the bitmap/icon")
  - Always call GlobalUnlock16 after GlobalLock16

-------------- next part --------------
--- static-old.c	2006-01-11 22:30:38.000000000 +0100
+++ static.c	2006-01-11 22:34:52.000000000 +0100
@@ -30,7 +30,6 @@
  *
  *   Styles
  *   - SS_REALSIZECONTROL
- *   - SS_REALSIZEIMAGE
  *   - SS_RIGHTJUST
  *
  *   Notifications
@@ -119,20 +118,33 @@
 static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
 {
     HICON prevIcon;
-    CURSORICONINFO *info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
-
+    CURSORICONINFO * info;
+    
     if ((style & SS_TYPEMASK) != SS_ICON) return 0;
+    info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
     if (hicon && !info) {
-	ERR("hicon != 0, but info == 0\n");
-    	return 0;
+        WARN("hicon != 0, but info == 0\n");
+        return 0;
     }
     prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
-    if (hicon && !(style & SS_CENTERIMAGE))
+    if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
     {
-        SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
-                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
-        GlobalUnlock16(HICON_16(hicon));
+        /* Windows currently doesn't implement SS_RIGHTJUST */
+        /*
+        if ((style & SS_RIGHTJUST) != 0)
+        {
+            RECT wr;
+            GetWindowRect(hwnd, &wr);
+            SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
+                          info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
+        }
+        else */
+        {
+            SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
+                          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
+        }
     }
+    if (info) GlobalUnlock16(HICON_16(hicon));
     return prevIcon;
 }
 
@@ -147,16 +159,29 @@
 
     if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
     if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
-	ERR("hBitmap != 0, but it's not a bitmap\n");
-    	return 0;
+        WARN("hBitmap != 0, but it's not a bitmap\n");
+        return 0;
     }
     hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
-    if (hBitmap && !(style & SS_CENTERIMAGE))
+    if (hBitmap && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
     {
         BITMAP bm;
         GetObjectW(hBitmap, sizeof(bm), &bm);
-        SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
-		      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
+        /* Windows currently doesn't implement SS_RIGHTJUST */
+        /*
+        if ((style & SS_RIGHTJUST) != 0)
+        {
+            RECT wr;
+            GetWindowRect(hwnd, &wr);
+            SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
+                          bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
+        }
+        else */
+        {
+            SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
+                          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
+        }
+	
     }
     return hOldBitmap;
 }
@@ -170,7 +195,7 @@
 {
     if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
     if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
-        ERR("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
+        WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
         return 0;
     }
     return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );


More information about the wine-patches mailing list