[ros-diffs] [jgardou] 48673: [USER32] - Use Screen capabilities to create icons bitmaps.

jgardou at svn.reactos.org jgardou at svn.reactos.org
Wed Sep 1 10:56:12 UTC 2010


Author: jgardou
Date: Wed Sep  1 10:56:10 2010
New Revision: 48673

URL: http://svn.reactos.org/svn/reactos?rev=48673&view=rev
Log:
[USER32]
  - Use Screen capabilities to create icons bitmaps.

Modified:
    branches/reactos-yarotows/dll/win32/user32/windows/cursoricon.c

Modified: branches/reactos-yarotows/dll/win32/user32/windows/cursoricon.c
URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/dll/win32/user32/windows/cursoricon.c?rev=48673&r1=48672&r2=48673&view=diff
==============================================================================
--- branches/reactos-yarotows/dll/win32/user32/windows/cursoricon.c [iso-8859-1] (original)
+++ branches/reactos-yarotows/dll/win32/user32/windows/cursoricon.c [iso-8859-1] Wed Sep  1 10:56:10 2010
@@ -458,10 +458,16 @@
     void *color_bits, *mask_bits;
     BOOL ret = FALSE;
     HDC hdc = 0;
+	static HDC hScreenDC = 0;
 
     if (!(info = HeapAlloc( GetProcessHeap(), 0, max( size, FIELD_OFFSET( BITMAPINFO, bmiColors[2] )))))
         return FALSE;
-    if (!(hdc = CreateCompatibleDC( 0 ))) goto done;
+	if(!hScreenDC)
+	{
+		hScreenDC = GetDC(0);
+		if(!hScreenDC) goto done;
+	}
+    if (!(hdc = CreateCompatibleDC(hScreenDC))) goto done;
 
     memcpy( info, bmi, size );
     info->bmiHeader.biHeight /= 2;
@@ -485,8 +491,8 @@
     else
     {
         if (!(*mask = CreateBitmap( width, height, 1, 1, NULL ))) goto done;
-        if (!(*color = CreateBitmap( width, height, bmi->bmiHeader.biPlanes,
-                                     bmi->bmiHeader.biBitCount, NULL )))
+        if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hScreenDC, PLANES),
+                                     GetDeviceCaps(hScreenDC, BITSPIXEL), NULL )))
         {
             DeleteObject( *mask );
             goto done;
@@ -523,7 +529,7 @@
     ret = TRUE;
 
 done:
-    DeleteDC( hdc );
+    if(hdc) DeleteDC( hdc );
     HeapFree( GetProcessHeap(), 0, info );
     return ret;
 }




More information about the Ros-diffs mailing list