Esempio n. 1
0
/*****************************************************************************
 * SIC_Initialize			[internal]
 */
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 = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(IDI_SHELL_DOCUMENT),
                                IMAGE_ICON, cx_small, cy_small, LR_SHARED);
        hLg = 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;
}
Esempio n. 2
0
/****************************************************************************
 * SIC_LoadIcon				[internal]
 *
 * NOTES
 *  gets small/big icon by number from a file
 */
static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
{	HICON	hiconLarge=0;
	HICON	hiconSmall=0;
	HICON 	hiconLargeShortcut;
	HICON	hiconSmallShortcut;

        PrivateExtractIconsW( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 );
        PrivateExtractIconsW( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 );

	if ( !hiconLarge ||  !hiconSmall)
	{
	  WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall);
	  return -1;
	}

	if (0 != (dwFlags & GIL_FORSHORTCUT))
	{
	  hiconLargeShortcut = SIC_OverlayShortcutImage(hiconLarge, TRUE);
	  hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE);
	  if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut)
	  {
	    hiconLarge = hiconLargeShortcut;
	    hiconSmall = hiconSmallShortcut;
	  }
	  else
	  {
	    WARN("Failed to create shortcut overlayed icons\n");
	    if (NULL != hiconLargeShortcut) DestroyIcon(hiconLargeShortcut);
	    if (NULL != hiconSmallShortcut) DestroyIcon(hiconSmallShortcut);
	    dwFlags &= ~ GIL_FORSHORTCUT;
	  }
	}

	return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags);
}
Esempio n. 3
0
/****************************************************************************
 * SIC_LoadIcon				[internal]
 *
 * NOTES
 *  gets small/big icon by number from a file
 */
static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
{	HICON	hiconLarge=0;
	HICON	hiconSmall=0;

        PrivateExtractIconsA( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 );
        PrivateExtractIconsA( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 );

	if ( !hiconLarge ||  !hiconSmall)
	{
	  WARN("failure loading icon %i from %s (%x %x)\n", dwSourceIndex, sSourceFile, hiconLarge, hiconSmall);
	  return -1;
	}
	return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
}
Esempio n. 4
0
/*****************************************************************************
 * SIC_Initialize			[internal]
 *
 * NOTES
 *  hack to load the resources from the shell32.dll under a different dll name
 *  will be removed when the resource-compiler is ready
 */
BOOL SIC_Initialize(void)
{
	HICON		hSm, hLg;
	UINT		index;

	TRACE("\n");

	if (sic_hdpa)	/* already initialized?*/
	  return TRUE;

	sic_hdpa = pDPA_Create(16);

	if (!sic_hdpa)
	{
	  return(FALSE);
	}

	ShellSmallIconList = ImageList_Create(16,16,ILC_COLORDDB | ILC_MASK,0,0x20);
	ShellBigIconList = ImageList_Create(32,32,ILC_COLORDDB | ILC_MASK,0,0x20);

	ImageList_SetBkColor(ShellSmallIconList, GetSysColor(COLOR_WINDOW));
	ImageList_SetBkColor(ShellBigIconList, GetSysColor(COLOR_WINDOW));

	for (index=1; index<39; index++)
	{
	  hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 16, 16,LR_SHARED);
	  hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 32, 32,LR_SHARED);

	  if(!hSm)
	  {
	    hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 16, 16,LR_SHARED);
	    hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 32, 32,LR_SHARED);
	  }
	  SIC_IconAppend ("shell32.dll", index, hSm, hLg);
	}

	TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);

	return TRUE;
}
Esempio n. 5
0
/*****************************************************************************
 * SIC_Initialize            [internal]
 */
BOOL SIC_Initialize(void)
{
    HICON hSm = NULL, hLg = NULL;
    INT cx_small, cy_small;
    INT cx_large, cy_large;
    HDC hDC;
    INT bpp;
    DWORD ilMask;
    BOOL result = FALSE;

    TRACE("Entered SIC_Initialize\n");

    if (sic_hdpa)
    {
        TRACE("Icon cache already initialized\n");
        return TRUE;
    }

    sic_hdpa = DPA_Create(16);
    if (!sic_hdpa)
    {
        return FALSE;
    }

    hDC = CreateICW(L"DISPLAY", NULL, NULL, NULL);
    if (!hDC)
    {
        ERR("Failed to create information context (error %d)\n", GetLastError());
        goto end;
    }

    bpp = GetDeviceCaps(hDC, BITSPIXEL);
    DeleteDC(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)
    {
        ERR("Failed to create the small icon list.\n");
        goto end;
    }

    ShellBigIconList = ImageList_Create(cx_large,
                                        cy_large,
                                        ilMask,
                                        100,
                                        100);
    if (!ShellBigIconList)
    {
        ERR("Failed to create the big icon list.\n");
        goto end;
    }
    
    /* 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);
    if (!hSm)
    {
        ERR("Failed to load small IDI_SHELL_DOCUMENT icon!\n");
        goto end;
    }

    hLg = (HICON)LoadImageW(shell32_hInstance,
                            MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT),
                            IMAGE_ICON,
                            cx_large,
                            cy_large,
                            LR_SHARED | LR_DEFAULTCOLOR);
    if (!hLg)
    {
        ERR("Failed to load large IDI_SHELL_DOCUMENT icon!\n");
        goto end;
    }

    if(SIC_IconAppend(swShell32Name, IDI_SHELL_DOCUMENT-1, hSm, hLg, 0) == INVALID_INDEX)
    {
        ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
        goto end;
    }
    if(SIC_IconAppend(swShell32Name, -IDI_SHELL_DOCUMENT, hSm, hLg, 0) == INVALID_INDEX)
    {
        ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
        goto end;
    }
    
    /* Everything went fine */
    result = TRUE;
    
end:
    /* The image list keeps a copy of the icons, we must destroy them */
    if(hSm) DestroyIcon(hSm);
    if(hLg) DestroyIcon(hLg);
    
    /* Clean everything if something went wrong */
    if(!result)
    {
        if(sic_hdpa) DPA_Destroy(sic_hdpa);
        if(ShellSmallIconList) ImageList_Destroy(ShellSmallIconList);
        if(ShellBigIconList) ImageList_Destroy(ShellSmallIconList);
        sic_hdpa = NULL;
        ShellSmallIconList = NULL;
        ShellBigIconList = NULL;
    }

    TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);

    return result;
}