Sergey Guralnik : user32: Add internal class small icons.

Alexandre Julliard julliard at winehq.org
Mon Oct 15 14:29:07 CDT 2012


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

Author: Sergey Guralnik <serhio at etersoft.ru>
Date:   Fri Oct 12 10:36:10 2012 +0400

user32: Add internal class small icons.

---

 dlls/user32/class.c       |   32 +++++++++++++++++++++++++++++---
 dlls/user32/tests/class.c |    5 -----
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index 8b5060a..a66f0db 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -56,6 +56,7 @@ typedef struct tagCLASS
     HINSTANCE        hInstance;     /* Module that created the task */
     HICON            hIcon;         /* Default icon */
     HICON            hIconSm;       /* Default small icon */
+    HICON            hIconSmIntern; /* Internal small icon, derived from hIcon */
     HCURSOR          hCursor;       /* Default cursor */
     HBRUSH           hbrBackground; /* Default background */
     ATOM             atomName;      /* Name of the class */
@@ -518,6 +519,10 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
 
     classPtr->hIcon         = wc->hIcon;
     classPtr->hIconSm       = wc->hIconSm;
+    classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
+                                            CopyImage( wc->hIcon, IMAGE_ICON,
+                                                GetSystemMetrics( SM_CXSMICON ),
+                                                GetSystemMetrics( SM_CYSMICON ), 0 ) : NULL;
     classPtr->hCursor       = wc->hCursor;
     classPtr->hbrBackground = wc->hbrBackground;
     classPtr->winproc       = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
@@ -556,6 +561,10 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
 
     classPtr->hIcon         = wc->hIcon;
     classPtr->hIconSm       = wc->hIconSm;
+    classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
+                                            CopyImage( wc->hIcon, IMAGE_ICON,
+                                                GetSystemMetrics( SM_CXSMICON ),
+                                                GetSystemMetrics( SM_CYSMICON ), 0 ) : NULL;
     classPtr->hCursor       = wc->hCursor;
     classPtr->hbrBackground = wc->hbrBackground;
     classPtr->winproc       = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
@@ -741,7 +750,7 @@ static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
         retvalue = (ULONG_PTR)class->hIcon;
         break;
     case GCLP_HICONSM:
-        retvalue = (ULONG_PTR)class->hIconSm;
+        retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
         break;
     case GCL_STYLE:
         retvalue = class->style;
@@ -884,10 +893,27 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
         break;
     case GCLP_HICON:
         retval = (ULONG_PTR)class->hIcon;
+        if (retval && class->hIconSmIntern)
+        {
+            DestroyIcon(class->hIconSmIntern);
+            class->hIconSmIntern = NULL;
+        }
+        if (newval && !class->hIconSm)
+            class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
+                      GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
         class->hIcon = (HICON)newval;
         break;
     case GCLP_HICONSM:
         retval = (ULONG_PTR)class->hIconSm;
+        if (retval && !newval)
+            class->hIconSmIntern = class->hIcon ? CopyImage( class->hIcon, IMAGE_ICON,
+                                                GetSystemMetrics( SM_CXSMICON ),
+                                                GetSystemMetrics( SM_CYSMICON ), 0 ) : NULL;
+        else if (!retval && newval && class->hIconSmIntern)
+        {
+            DestroyIcon(class->hIconSmIntern);
+            class->hIconSmIntern = NULL;
+        }
         class->hIconSm = (HICON)newval;
         break;
     case GCL_STYLE:
@@ -1099,7 +1125,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
     wc->cbWndExtra    = classPtr->cbWndExtra;
     wc->hInstance     = (hInstance == user32_module) ? 0 : hInstance;
     wc->hIcon         = classPtr->hIcon;
-    wc->hIconSm       = classPtr->hIconSm;
+    wc->hIconSm       = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
     wc->hCursor       = classPtr->hCursor;
     wc->hbrBackground = classPtr->hbrBackground;
     wc->lpszMenuName  = CLASS_GetMenuNameA( classPtr );
@@ -1141,7 +1167,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
     wc->cbWndExtra    = classPtr->cbWndExtra;
     wc->hInstance     = (hInstance == user32_module) ? 0 : hInstance;
     wc->hIcon         = classPtr->hIcon;
-    wc->hIconSm       = classPtr->hIconSm;
+    wc->hIconSm       = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
     wc->hCursor       = classPtr->hCursor;
     wc->hbrBackground = classPtr->hbrBackground;
     wc->lpszMenuName  = CLASS_GetMenuNameW( classPtr );
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c
index 8e4be6a..2f497a5 100644
--- a/dlls/user32/tests/class.c
+++ b/dlls/user32/tests/class.c
@@ -999,11 +999,9 @@ static void test_icons(void)
 
     ok(GetClassInfoExW(hinst, cls_name, &ret_wcex), "Class info was not retrieved\n");
     ok(wcex.hIcon == ret_wcex.hIcon, "Icons don't match\n");
-todo_wine
     ok(ret_wcex.hIconSm != NULL, "hIconSm should be non-zero handle\n");
 
     hsmicon = (HICON)GetClassLongPtrW(hwnd, GCLP_HICONSM);
-todo_wine
     ok(hsmicon != NULL, "GetClassLong should return non-zero handle\n");
 
     hsmallnew = CopyImage(wcex.hIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
@@ -1016,7 +1014,6 @@ todo_wine
 
     SetClassLongPtrW(hwnd, GCLP_HICONSM, 0);
     hsmicon = (HICON)GetClassLongPtrW(hwnd, GCLP_HICONSM);
-todo_wine
     ok( hsmicon != NULL, "GetClassLong should return non-zero handle\n");
 
     SetClassLongPtrW(hwnd, GCLP_HICON, 0);
@@ -1024,10 +1021,8 @@ todo_wine
 
     SetClassLongPtrW(hwnd, GCLP_HICON, (LONG_PTR)LoadIconW(NULL, (LPCWSTR)IDI_QUESTION));
     hsmicon = (HICON)GetClassLongPtrW(hwnd, GCLP_HICONSM);
-todo_wine
     ok(hsmicon != NULL, "GetClassLong should return non-zero handle\n");
     UnregisterClassW(cls_name, hinst);
-todo_wine
     ok(GetIconInfo(hsmicon, &icinf), "Icon should NOT be destroyed\n");
 
     DestroyIcon(hsmallnew);




More information about the wine-cvs mailing list