Create the system and device imagelists with the correct bpp

Do the same with the explorer stuff

svn path=/trunk/; revision=40297
This commit is contained in:
Ged Murphy
2009-03-30 19:08:16 +00:00
parent 47bdeaf2b9
commit 96c892841a
5 changed files with 161 additions and 38 deletions
@@ -152,7 +152,30 @@ int MainFrameBase::OpenShellFolders(LPIDA pida, HWND hFrameWnd)
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);
@@ -58,8 +58,31 @@ ShellBrowser::ShellBrowser(HWND hwnd, HWND hwndFrame, HWND left_hwnd, WindowHand
_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()
+31 -2
View File
@@ -480,10 +480,12 @@ SetupDiGetClassImageListExW(
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,12 +531,39 @@ SetupDiGetClassImageListExW(
/* 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 */
for (i = 0; i < list->NumberOfGuids; i++)
@@ -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>
+80 -33
View File
@@ -375,51 +375,98 @@ INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags )
*/
BOOL SIC_Initialize(void)
{
HICON hSm, hLg;
int cx_small, cy_small;
int cx_large, cy_large;
HICON hSm = NULL, hLg = NULL;
INT cx_small, cy_small;
INT cx_large, cy_large;
HDC hDC;
INT bpp;
DWORD ilMask;
cx_small = GetSystemMetrics(SM_CXSMICON);
cy_small = GetSystemMetrics(SM_CYSMICON);
cx_large = GetSystemMetrics(SM_CXICON);
cy_large = GetSystemMetrics(SM_CYICON);
TRACE("Entered SIC_Initialize\n");
TRACE("\n");
if (sic_hdpa) /* already initialized?*/
{
return TRUE;
}
if (sic_hdpa) /* already initialized?*/
return TRUE;
sic_hdpa = DPA_Create(16);
if (!sic_hdpa)
{
return FALSE;
}
sic_hdpa = DPA_Create(16);
hDC = GetDC(NULL);
if (!hDC)
{
return FALSE;
}
if (!sic_hdpa)
{
return(FALSE);
}
bpp = GetDeviceCaps(hDC, BITSPIXEL);
ReleaseDC(NULL, hDC);
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);
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;
ImageList_SetBkColor(ShellSmallIconList, CLR_NONE);
ImageList_SetBkColor(ShellBigIconList, CLR_NONE);
ilMask |= ILC_MASK;
/* 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);
cx_small = GetSystemMetrics(SM_CXSMICON);
cy_small = GetSystemMetrics(SM_CYSMICON);
cx_large = GetSystemMetrics(SM_CXICON);
cy_large = GetSystemMetrics(SM_CYICON);
if (!hSm || !hLg)
{
FIXME("Failed to load IDI_SHELL_DOCUMENT icon!\n");
return FALSE;
}
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);
}
SIC_IconAppend (swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0);
SIC_IconAppend (swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0);
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);
}
TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
if (!hSm || !hLg)
{
FIXME("Failed to load IDI_SHELL_DOCUMENT icon!\n");
return FALSE;
}
return TRUE;
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