[User32]
[reactos.git] / reactos / dll / win32 / user32 / controls / static.c
index a85221e..d421eae 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
  * NOTES
  *
@@ -53,10 +53,10 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
 static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
-//static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
+static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
-static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
-static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
+//static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
+//static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
 
 static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
 
@@ -68,7 +68,7 @@ static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
 
 typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
 
-static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
+static const pfPaint staticPaintFunc[SS_TYPEMASK+1] =
 {
     STATIC_PaintTextfn,      /* SS_LEFT */
     STATIC_PaintTextfn,      /* SS_CENTER */
@@ -85,7 +85,7 @@ static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
     STATIC_PaintTextfn,      /* SS_LEFTNOWORDWRAP */
     STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
     STATIC_PaintBitmapfn,    /* SS_BITMAP */
-    NULL,                    /* STATIC_PaintEnhMetafn, SS_ENHMETAFILE */
+    STATIC_PaintEnhMetafn,   /* SS_ENHMETAFILE */
     STATIC_PaintEtchedfn,    /* SS_ETCHEDHORZ */
     STATIC_PaintEtchedfn,    /* SS_ETCHEDVERT */
     STATIC_PaintEtchedfn,    /* SS_ETCHEDFRAME */
@@ -95,9 +95,10 @@ static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
 /*********************************************************************
  * static class descriptor
  */
+static const WCHAR staticW[] = {'S','t','a','t','i','c',0};
 const struct builtin_class_descr STATIC_builtin_class =
 {
-    L"Static",            /* name */
+    staticW,             /* name */
     CS_DBLCLKS | CS_PARENTDC, /* style  */
     StaticWndProcA,      /* procA */
     StaticWndProcW,      /* procW */
@@ -106,9 +107,10 @@ const struct builtin_class_descr STATIC_builtin_class =
     0                    /* brush */
 };
 
+/* REACTOS ONLY */
 static __inline void set_ui_state( HWND hwnd, LONG flags )
 {
-    SetWindowLongW( hwnd, UISTATE_GWL_OFFSET, flags );
+    SetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET, flags );
 }
 
 static __inline LONG get_ui_state( HWND hwnd )
@@ -116,6 +118,29 @@ static __inline LONG get_ui_state( HWND hwnd )
     return GetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET );
 }
 
+/* Retrieve the UI state for the control */
+static BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode)
+{
+    LONG flags, prevflags;
+
+    if (unicode)
+        flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0);
+    else
+        flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0);
+
+    prevflags = get_ui_state(hwnd);
+
+    if (prevflags != flags)
+    {
+        set_ui_state(hwnd, flags);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/* END REACTOS ONLY */
+
 static void setup_clipping(HWND hwnd, HDC hdc, HRGN *orig)
 {
     RECT rc;
@@ -144,27 +169,6 @@ static void restore_clipping(HDC hdc, HRGN hrgn)
         DeleteObject(hrgn);
 }
 
-/* Retrieve the UI state for the control */
-static BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode)
-{
-    LONG flags, prevflags;
-
-    if (unicode)
-        flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0);
-    else
-        flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0);
-
-    prevflags = get_ui_state(hwnd);
-
-    if (prevflags != flags)
-    {
-        set_ui_state(hwnd, flags);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
 /***********************************************************************
  *           STATIC_SetIcon
  *
@@ -241,6 +245,7 @@ static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
             SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
                           SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
         }
+
     }
     return hOldBitmap;
 }
@@ -250,15 +255,15 @@ static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
  *
  * Set the enhanced metafile for an SS_ENHMETAFILE control.
  */
-//static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
-//{
-//    if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
-//    if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
-//        WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
-//        return 0;
-//    }
-//    return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
-//}
+static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
+{
+    if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
+    if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
+        WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
+        return 0;
+    }
+    return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
+}
 
 /***********************************************************************
  *           STATIC_GetImage
@@ -291,23 +296,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)
+    HICON hicon = 0;
+
+    if (hInstance && ((ULONG_PTR)hInstance >> 16))
     {
-        return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
+        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 );
+        }
     }
-    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 */
+    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;
-    }
 }
 
 /***********************************************************************
@@ -315,48 +322,27 @@ 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 = 0;
+
+    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 );
+       }
     }
+    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;
 }
 
-/***********************************************************************
- *           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 );
-}
 
 /***********************************************************************
  *           STATIC_TryPaintFcn
@@ -387,14 +373,14 @@ static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
     HBRUSH hBrush;
     HWND parent = GetParent(hwnd);
 
-    if(!parent) parent = hwnd;
-    hBrush = (HBRUSH) SendMessageW( GetParent(hwnd),
+    if (!parent) parent = hwnd;
+    hBrush = (HBRUSH) SendMessageW( parent,
                     WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
     if (!hBrush) /* did the app forget to call DefWindowProc ? */
     {
         /* FIXME: DefWindowProc should return different colors if a
                   manifest is present */
-        hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+        hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC,
                                         (WPARAM)hdc, (LPARAM)hwnd);
     }
     return hBrush;
@@ -431,12 +417,24 @@ static BOOL hasTextStyle( DWORD style )
 /***********************************************************************
  *           StaticWndProc_common
  */
-static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
+LRESULT WINAPI StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
                                      LPARAM lParam, BOOL unicode )
 {
     LRESULT lResult = 0;
-    LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
+    LONG full_style = GetWindowLongPtrW( hwnd, GWL_STYLE );
     LONG style = full_style & SS_TYPEMASK;
+#ifdef __REACTOS__
+    PWND pWnd;
+
+    pWnd = ValidateHwnd(hwnd);
+    if (pWnd)
+    {
+       if (!pWnd->fnid)
+       {
+          NtUserSetWindowFNID(hwnd, FNID_STATIC);
+       }
+    }    
+#endif    
 
     switch (uMsg)
     {
@@ -451,6 +449,9 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
         break;
 
     case WM_NCDESTROY:
+#ifdef __REACTOS__
+        NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+#endif
         if (style == SS_ICON) {
 /*
  * FIXME
@@ -508,10 +509,11 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
         {
             LPCSTR textA;
             LPCWSTR textW;
+            HINSTANCE hInstance;
 
             if (full_style & SS_SUNKEN)
-                SetWindowLongW( hwnd, GWL_EXSTYLE,
-                                GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
+                SetWindowLongPtrW( hwnd, GWL_EXSTYLE,
+                                   GetWindowLongPtrW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
 
             if(unicode)
             {
@@ -522,26 +524,30 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
             {
                 textA = ((LPCREATESTRUCTA)lParam)->lpszName;
                 textW = NULL;
+                
             }
 
+            hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
+
             switch (style) {
             case SS_ICON:
                 {
                     HICON hIcon;
-                    if(unicode)
-                       hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
+                    if(unicode )
+                       hIcon = STATIC_LoadIconW(hInstance, textW, full_style);
                     else
-                       hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
+                       hIcon = STATIC_LoadIconA(hInstance, textA, full_style);
                     STATIC_SetIcon(hwnd, hIcon, full_style);
                 }
                 break;
             case SS_BITMAP:
+                if ((ULONG_PTR)hInstance >> 16)
                 {
                     HBITMAP hBitmap;
                     if(unicode)
-                        hBitmap = STATIC_LoadBitmapW(hwnd, textW);
+                        hBitmap = LoadBitmapW(hInstance, textW);
                     else
-                        hBitmap = STATIC_LoadBitmapA(hwnd, textA);
+                        hBitmap = LoadBitmapA(hInstance, textA);
                     STATIC_SetBitmap(hwnd, hBitmap, full_style);
                 }
                 break;
@@ -570,8 +576,8 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
         if (hasTextStyle( full_style ))
         {
             SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
-        if (LOWORD(lParam))
-            RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
+            if (LOWORD(lParam))
+                RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
         }
         break;
 
@@ -603,34 +609,32 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
 
     case STM_GETIMAGE:
         return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
-#ifndef __REACTOS__
-    case STM_GETICON16:
-#endif
+
     case STM_GETICON:
         return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
 
     case STM_SETIMAGE:
         switch(wParam) {
        case IMAGE_BITMAP:
+           if (style != SS_BITMAP) return 0;
            lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
            break;
-//     case IMAGE_ENHMETAFILE:
-//         lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
-//         break;
+       case IMAGE_ENHMETAFILE:
+           if (style != SS_ENHMETAFILE) return 0;
+           lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
+           break;
        case IMAGE_ICON:
        case IMAGE_CURSOR:
+           if (style != SS_ICON) return 0;
            lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
            break;
        default:
-           FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
+           FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam);
            break;
        }
         STATIC_TryPaintFcn( hwnd, full_style );
        break;
 
-#ifndef __REACTOS__
-    case STM_SETICON16:
-#endif
     case STM_SETICON:
         lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
         STATIC_TryPaintFcn( hwnd, full_style );
@@ -658,7 +662,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
 /***********************************************************************
  *           StaticWndProcA
  */
-static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
 {
     if (!IsWindow( hWnd )) return 0;
     return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
@@ -667,7 +671,7 @@ static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 /***********************************************************************
  *           StaticWndProcW
  */
-static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
 {
     if (!IsWindow( hWnd )) return 0;
     return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
@@ -701,7 +705,7 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
     RECT rc;
     HBRUSH hBrush;
     HFONT hFont, hOldFont = NULL;
-    DWORD wFormat;
+    WORD wFormat;
     INT len, buf_size;
     WCHAR *text;
 
@@ -733,6 +737,9 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
         return;
     }
 
+    if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_RIGHT)
+        wFormat = DT_RIGHT | (wFormat & ~(DT_LEFT | DT_CENTER));
+
     if (style & SS_NOPREFIX)
         wFormat |= DT_NOPREFIX;
     else if (get_ui_state(hwnd) & UISF_HIDEACCEL)
@@ -753,7 +760,7 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
     }
 
     if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET )))
-        hOldFont = (HFONT)SelectObject( hdc, hFont );
+        hOldFont = SelectObject( hdc, hFont );
 
     /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
                            brush is not used */
@@ -806,6 +813,9 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
     GetClientRect( hwnd, &rc);
 
     /* FIXME: send WM_CTLCOLORSTATIC */
+#ifdef __REACTOS__
+    hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc); // Always sent....
+#endif
     switch (style & SS_TYPEMASK)
     {
     case SS_BLACKRECT:
@@ -838,31 +848,28 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
     DeleteObject( hBrush );
 }
 
-/* Modified for ReactOS */
 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
 {
     RECT rc, iconRect;
     HBRUSH hbrush;
     HICON hIcon;
-    ICONINFO info;
+    SIZE size;
 
     GetClientRect( hwnd, &rc );
     hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
     hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
-    if (!hIcon || (!GetIconInfo(hIcon, &info)))
+    if (!hIcon || !get_icon_size( hIcon, &size ))
     {
         FillRect(hdc, &rc, hbrush);
     }
     else
     {
-        BITMAP bm;
-        if (!GetObjectW(info.hbmColor, sizeof(BITMAP), &bm)) return;
         if (style & SS_CENTERIMAGE)
         {
-            iconRect.left = (rc.right - rc.left) / 2 - bm.bmWidth / 2;
-            iconRect.top = (rc.bottom - rc.top) / 2 - bm.bmHeight / 2;
-            iconRect.right = iconRect.left + bm.bmWidth;
-            iconRect.bottom = iconRect.top + bm.bmHeight;
+            iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
+            iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
+            iconRect.right = iconRect.left + size.cx;
+            iconRect.bottom = iconRect.top + size.cy;
         }
         else
             iconRect = rc;
@@ -899,7 +906,7 @@ static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
             if (brush.lbStyle == BS_SOLID)
                 SetBkColor(hdc, brush.lbColor);
         }
-            GetClientRect(hwnd, &rcClient);
+        GetClientRect(hwnd, &rcClient);
         if (style & SS_CENTERIMAGE)
         {
             INT x, y;
@@ -918,32 +925,26 @@ static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
         SelectObject(hMemDC, oldbitmap);
         DeleteDC(hMemDC);
     }
-    else
-    {
-        RECT rcClient;
-        GetClientRect( hwnd, &rcClient );
-        FillRect( hdc, &rcClient, hbrush );
-    }
 }
 
 
-//static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
-//{
-//    HENHMETAFILE hEnhMetaFile;
-//    RECT rc;
-//    HBRUSH hbrush;
-//
-//    GetClientRect(hwnd, &rc);
-//    hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
-//    FillRect(hdc, &rc, hbrush);
-//    if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
-//    {
-//        /* The control's current font is not selected into the
-//           device context! */
-//        if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
-//            PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
-//    }
-//}
+static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
+{
+    HENHMETAFILE hEnhMetaFile;
+    RECT rc;
+    HBRUSH hbrush;
+
+    GetClientRect(hwnd, &rc);
+    hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
+    FillRect(hdc, &rc, hbrush);
+    if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
+    {
+        /* The control's current font is not selected into the
+           device context! */
+        if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
+            PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
+    }
+}
 
 
 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
@@ -965,3 +966,4 @@ static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
            break;
     }
 }
+