summaryrefslogtreecommitdiffstats
path: root/win/tkWinWm.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-09-10 04:50:44 (GMT)
committerhobbs <hobbs>2004-09-10 04:50:44 (GMT)
commit8815a1d254c8262b81a53c8ee780af5a44052efa (patch)
treef829cd549b408d69143950059faa9ff45501f0e9 /win/tkWinWm.c
parent7d84639cc81ee8b65a810da62e52c02daa58e47d (diff)
downloadtk-8815a1d254c8262b81a53c8ee780af5a44052efa.zip
tk-8815a1d254c8262b81a53c8ee780af5a44052efa.tar.gz
tk-8815a1d254c8262b81a53c8ee780af5a44052efa.tar.bz2
* win/tkWinWm.c (ReadIconFromFile): when using SHGetFileInfo to
retrieve icon, get regular icon as well for correct Alt-Tab icon.
Diffstat (limited to 'win/tkWinWm.c')
-rw-r--r--win/tkWinWm.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 4fff379..5e5e39a 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.64 2004/08/20 00:58:52 hobbs Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.65 2004/09/10 04:50:44 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -1182,44 +1182,67 @@ ReadIconFromFile(interp, fileName)
/* First check if it is a .ico file */
BlockOfIconImagesPtr lpIR;
lpIR = ReadIconOrCursorFromFile(interp, fileName, TRUE);
-
- /* Then see if we can ask the shell for the icon for this file */
+
+ /*
+ * Then see if we can ask the shell for the icon for this file.
+ * We want both the regular and small icons so that the Alt-Tab
+ * (task-switching) display uses the right icon.
+ */
if (lpIR == NULL && shgetfileinfoProc != NULL) {
+ SHFILEINFO sfiSM;
SHFILEINFO sfi;
Tcl_DString ds, ds2;
DWORD *res;
CONST char *file;
-
+
file = Tcl_TranslateFileName(interp, Tcl_GetString(fileName), &ds);
if (file == NULL) { return NULL; }
Tcl_UtfToExternalDString(NULL, file, -1, &ds2);
Tcl_DStringFree(&ds);
-
- res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfi,
- sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
-
- Tcl_DStringFree(&ds2);
-
+ res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfiSM,
+ sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
+
if (res != 0) {
Tcl_ResetResult(interp);
-
- lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages));
+ res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfi,
+ sizeof(SHFILEINFO), SHGFI_ICON);
+
+ /* Account for extra icon, if necessary */
+ lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages)
+ + (res != 0) ? sizeof(ICONIMAGE) : 0);
if (lpIR == NULL) {
- DestroyIcon(sfi.hIcon);
+ if (res != 0) {
+ DestroyIcon(sfi.hIcon);
+ }
+ DestroyIcon(sfiSM.hIcon);
+ Tcl_DStringFree(&ds2);
return NULL;
}
-
- lpIR->nNumImages = 1;
- lpIR->IconImages[0].Width = 16;
- lpIR->IconImages[0].Height = 16;
- lpIR->IconImages[0].Colors = 4;
- lpIR->IconImages[0].hIcon = sfi.hIcon;
+
+ lpIR->nNumImages = (res != 0) ? 2 : 1;
+ lpIR->IconImages[0].Width = 16;
+ lpIR->IconImages[0].Height = 16;
+ lpIR->IconImages[0].Colors = 4;
+ lpIR->IconImages[0].hIcon = sfiSM.hIcon;
/* These fields are ignored */
- lpIR->IconImages[0].lpBits = 0;
+ lpIR->IconImages[0].lpBits = 0;
lpIR->IconImages[0].dwNumBytes = 0;
- lpIR->IconImages[0].lpXOR = 0;
- lpIR->IconImages[0].lpAND = 0;
+ lpIR->IconImages[0].lpXOR = 0;
+ lpIR->IconImages[0].lpAND = 0;
+
+ if (res != 0) {
+ lpIR->IconImages[1].Width = 32;
+ lpIR->IconImages[1].Height = 32;
+ lpIR->IconImages[1].Colors = 4;
+ lpIR->IconImages[1].hIcon = sfi.hIcon;
+ /* These fields are ignored */
+ lpIR->IconImages[1].lpBits = 0;
+ lpIR->IconImages[1].dwNumBytes = 0;
+ lpIR->IconImages[1].lpXOR = 0;
+ lpIR->IconImages[1].lpAND = 0;
+ }
}
+ Tcl_DStringFree(&ds2);
}
if (lpIR != NULL) {
titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance));