[ros-diffs] [gedmurphy] 40297: Create the system and device imagelists with the correct bpp Do the same with the explorer stuff

gedmurphy at svn.reactos.org gedmurphy at svn.reactos.org
Mon Mar 30 21:08:18 CEST 2009


Author: gedmurphy
Date: Mon Mar 30 23:08:16 2009
New Revision: 40297

URL: http://svn.reactos.org/svn/reactos?rev=40297&view=rev
Log:
Create the system and device imagelists with the correct bpp
Do the same with the explorer stuff

Modified:
    trunk/reactos/base/shell/explorer/shell/mainframe.cpp
    trunk/reactos/base/shell/explorer/shell/shellbrowser.cpp
    trunk/reactos/dll/win32/setupapi/devclass.c
    trunk/reactos/dll/win32/setupapi/setupapi.rbuild
    trunk/reactos/dll/win32/shell32/iconcache.c

Modified: trunk/reactos/base/shell/explorer/shell/mainframe.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/shell/mainframe.cpp?rev=40297&r1=40296&r2=40297&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/shell/mainframe.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/shell/mainframe.cpp [iso-8859-1] Mon Mar 30 23:08:16 2009
@@ -152,7 +152,30 @@
 MainFrameBase::MainFrameBase(HWND hwnd)
  :	super(hwnd)
 {
-	_himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0);
+    HDC hDC = GetDC(NULL);
+    if (hDC)
+    {
+        DWORD ilMask;
+        INT bpp = GetDeviceCaps(hDC, BITSPIXEL);
+        ReleaseDC(NULL, hDC);
+
+        if (bpp <= 4)
+            ilMask = ILC_COLOR4;
+        else if (bpp <= 8)
+            ilMask = ILC_COLOR8;
+        else if (bpp <= 16)
+            ilMask = ILC_COLOR16;
+        else if (bpp <= 24)
+            ilMask = ILC_COLOR24;
+        else if (bpp <= 32)
+            ilMask = ILC_COLOR32;
+        else
+            ilMask = ILC_COLOR;
+
+        ilMask |= ILC_MASK;
+
+        _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ilMask, 2, 0);
+    }
 
 	_hMenuFrame = GetMenu(hwnd);
 	_hMenuWindow = GetSubMenu(_hMenuFrame, GetMenuItemCount(_hMenuFrame)-3);

Modified: trunk/reactos/base/shell/explorer/shell/shellbrowser.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/shell/shellbrowser.cpp?rev=40297&r1=40296&r2=40297&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer/shell/shellbrowser.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/shell/shellbrowser.cpp [iso-8859-1] Mon Mar 30 23:08:16 2009
@@ -58,8 +58,31 @@
 
 	_cur_dir = NULL;
 
-	_himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0);
-	ImageList_SetBkColor(_himl, GetSysColor(COLOR_WINDOW));
+    HDC hDC = GetDC(NULL);
+    if (hDC)
+    {
+        INT bpp = GetDeviceCaps(hDC, BITSPIXEL);
+        ReleaseDC(NULL, hDC);
+
+        DWORD ilMask;
+        if (bpp <= 4)
+            ilMask = ILC_COLOR4;
+        else if (bpp <= 8)
+            ilMask = ILC_COLOR8;
+        else if (bpp <= 16)
+            ilMask = ILC_COLOR16;
+        else if (bpp <= 24)
+            ilMask = ILC_COLOR24;
+        else if (bpp <= 32)
+            ilMask = ILC_COLOR32;
+        else
+            ilMask = ILC_COLOR;
+
+        ilMask |= ILC_MASK;
+
+        _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ilMask, 2, 0);
+        ImageList_SetBkColor(_himl, GetSysColor(COLOR_WINDOW));
+    }
 }
 
 ShellBrowser::~ShellBrowser()

Modified: trunk/reactos/dll/win32/setupapi/devclass.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/devclass.c?rev=40297&r1=40296&r2=40297&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/devclass.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/devclass.c [iso-8859-1] Mon Mar 30 23:08:16 2009
@@ -480,10 +480,12 @@
     else
     {
         struct ClassImageList *list = NULL;
+        HDC hDC;
         DWORD RequiredSize;
+        DWORD ilMask, bkColor;
         HICON hIcon;
         DWORD size;
-        INT i;
+        INT i, bpp;
 
         /* Get list of all class GUIDs in given computer */
         ret = SetupDiBuildClassInfoListExW(
@@ -529,11 +531,38 @@
 
         /* Prepare a HIMAGELIST */
         InitCommonControls();
-        ClassImageListData->ImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 100, 10);
+
+        hDC = GetDC(NULL);
+        if (!hDC)
+            goto cleanup;
+
+        bpp = GetDeviceCaps(hDC, BITSPIXEL);
+        ReleaseDC(NULL, hDC);
+
+        if (bpp <= 4)
+            ilMask = ILC_COLOR4;
+        else if (bpp <= 8)
+            ilMask = ILC_COLOR8;
+        else if (bpp <= 16)
+            ilMask = ILC_COLOR16;
+        else if (bpp <= 24)
+            ilMask = ILC_COLOR24;
+        else if (bpp <= 32)
+            ilMask = ILC_COLOR32;
+        else
+            ilMask = ILC_COLOR;
+
+        ilMask |= ILC_MASK;
+
+        ClassImageListData->ImageList = ImageList_Create(16, 16, ilMask, 100, 10);
         if (!ClassImageListData->ImageList)
             goto cleanup;
 
         ClassImageListData->Reserved = (ULONG_PTR)list;
+
+        /* For some reason, Windows sets the list background to COLOR_WINDOW */
+        bkColor = GetSysColor(COLOR_WINDOW);
+        ImageList_SetBkColor(ClassImageListData->ImageList, bkColor);
 
         /* Now, we "simply" need to load icons associated with all class guids,
          * and put their index in the image list in the IconIndexes array */

Modified: trunk/reactos/dll/win32/setupapi/setupapi.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi.rbuild?rev=40297&r1=40296&r2=40297&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/setupapi.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/setupapi.rbuild [iso-8859-1] Mon Mar 30 23:08:16 2009
@@ -10,6 +10,7 @@
 	<library>uuid</library>
 	<library>wine</library>
 	<library>ntdll</library>
+	<library>gdi32</library>
 	<library>comctl32</library>
 	<library>kernel32</library>
 	<library>advapi32</library>

Modified: trunk/reactos/dll/win32/shell32/iconcache.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/iconcache.c?rev=40297&r1=40296&r2=40297&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/iconcache.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/iconcache.c [iso-8859-1] Mon Mar 30 23:08:16 2009
@@ -375,51 +375,98 @@
  */
 BOOL SIC_Initialize(void)
 {
-	HICON		hSm, hLg;
-	int		cx_small, cy_small;
-	int		cx_large, cy_large;
-
-	cx_small = GetSystemMetrics(SM_CXSMICON);
-	cy_small = GetSystemMetrics(SM_CYSMICON);
-	cx_large = GetSystemMetrics(SM_CXICON);
-	cy_large = GetSystemMetrics(SM_CYICON);
-
-	TRACE("\n");
-
-	if (sic_hdpa)	/* already initialized?*/
-	  return TRUE;
-
-	sic_hdpa = DPA_Create(16);
-
-	if (!sic_hdpa)
-	{
-	  return(FALSE);
-	}
-
-        ShellSmallIconList = ImageList_Create(cx_small,cy_small,ILC_COLOR32|ILC_MASK,0,0x20);
-        ShellBigIconList = ImageList_Create(cx_large,cy_large,ILC_COLOR32|ILC_MASK,0,0x20);
-
-        ImageList_SetBkColor(ShellSmallIconList, CLR_NONE);
-        ImageList_SetBkColor(ShellBigIconList, CLR_NONE);
-
-        /* Load the document icon, which is used as the default if an icon isn't found. */
-        hSm = (HICON)LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(IDI_SHELL_DOCUMENT),
-                                IMAGE_ICON, cx_small, cy_small, LR_SHARED);
-        hLg = (HICON)LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(IDI_SHELL_DOCUMENT),
-                                IMAGE_ICON, cx_large, cy_large, LR_SHARED);
-
-        if (!hSm || !hLg)
-        {
-          FIXME("Failed to load IDI_SHELL_DOCUMENT icon!\n");
-          return FALSE;
-        }
-
-        SIC_IconAppend (swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0);
-        SIC_IconAppend (swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0);
-
-	TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
-
-	return TRUE;
+    HICON hSm = NULL, hLg = NULL;
+    INT cx_small, cy_small;
+    INT cx_large, cy_large;
+    HDC hDC;
+    INT bpp;
+    DWORD ilMask;
+
+    TRACE("Entered SIC_Initialize\n");
+
+    if (sic_hdpa) /* already initialized?*/
+    {
+        return TRUE;
+    }
+
+    sic_hdpa = DPA_Create(16);
+    if (!sic_hdpa)
+    {
+        return FALSE;
+    }
+
+    hDC = GetDC(NULL);
+    if (!hDC)
+    {
+        return FALSE;
+    }
+
+    bpp = GetDeviceCaps(hDC, BITSPIXEL);
+    ReleaseDC(NULL, hDC);
+
+    if (bpp <= 4)
+        ilMask = ILC_COLOR4;
+    else if (bpp <= 8)
+        ilMask = ILC_COLOR8;
+    else if (bpp <= 16)
+        ilMask = ILC_COLOR16;
+    else if (bpp <= 24)
+        ilMask = ILC_COLOR24;
+    else if (bpp <= 32)
+        ilMask = ILC_COLOR32;
+    else
+        ilMask = ILC_COLOR;
+
+    ilMask |= ILC_MASK;
+
+    cx_small = GetSystemMetrics(SM_CXSMICON);
+    cy_small = GetSystemMetrics(SM_CYSMICON);
+    cx_large = GetSystemMetrics(SM_CXICON);
+    cy_large = GetSystemMetrics(SM_CYICON);
+
+    ShellSmallIconList = ImageList_Create(cx_small,
+                                          cy_small,
+                                          ilMask,
+                                          100,
+                                          100);
+    if (ShellSmallIconList)
+    {
+         /* Load the document icon, which is used as the default if an icon isn't found. */
+        hSm = (HICON)LoadImageW(shell32_hInstance,
+                                MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT),
+                                IMAGE_ICON,
+                                cx_small,
+                                cy_small,
+                                LR_SHARED | LR_DEFAULTCOLOR);
+    }
+
+    ShellBigIconList = ImageList_Create(cx_large,
+                                        cy_large,
+                                        ilMask,
+                                        100,
+                                        100);
+    if (!ShellSmallIconList)
+    {
+        hLg = (HICON)LoadImageW(shell32_hInstance,
+                                MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT),
+                                IMAGE_ICON,
+                                cx_large,
+                                cy_large,
+                                LR_SHARED | LR_DEFAULTCOLOR);
+    }
+
+    if (!hSm || !hLg)
+    {
+      FIXME("Failed to load IDI_SHELL_DOCUMENT icon!\n");
+      return FALSE;
+    }
+
+    SIC_IconAppend(swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0);
+    SIC_IconAppend(swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0);
+
+    TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
+
+    return TRUE;
 }
 /*************************************************************************
  * SIC_Destroy



More information about the Ros-diffs mailing list