summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-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));