summaryrefslogtreecommitdiffstats
path: root/win/tkWinInit.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-11-24 15:15:25 (GMT)
committernijtmans <nijtmans>2010-11-24 15:15:25 (GMT)
commit95b5b6ee49c3dde98bbf1d7306e2909bbaa98ea9 (patch)
tree6ad5093200531d1cf762db7d61f52c09e520ff5e /win/tkWinInit.c
parente98b7d37a17da32d58fd2bbdc69ee041a6e8be50 (diff)
downloadtk-95b5b6ee49c3dde98bbf1d7306e2909bbaa98ea9.zip
tk-95b5b6ee49c3dde98bbf1d7306e2909bbaa98ea9.tar.gz
tk-95b5b6ee49c3dde98bbf1d7306e2909bbaa98ea9.tar.bz2
re-wrote TkpDisplayWarning such that it does not use an Tcl API calls any more, so it works even with an ill-initialized Tcl
Teach WishPanic how to thread UTF-8 in it's messagebox. Both of those changes backported from Tcl 8.6. No change in functionality.
Diffstat (limited to 'win/tkWinInit.c')
-rw-r--r--win/tkWinInit.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index 1a7f2be..b149996 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinInit.c,v 1.14 2007/12/13 15:28:55 dgp Exp $
+ * RCS: @(#) $Id: tkWinInit.c,v 1.14.2.1 2010/11/24 15:15:25 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -118,27 +118,21 @@ TkpDisplayWarning(
CONST char *msg, /* Message to be displayed. */
CONST char *title) /* Title of warning. */
{
- Tcl_DString msgString, titleString;
- Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding();
+#define TK_MAX_WARN_LEN 1024
+ WCHAR msgString[TK_MAX_WARN_LEN + 5];
+ WCHAR titleString[TK_MAX_WARN_LEN + 1];
+ MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, TK_MAX_WARN_LEN);
+ MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
/*
* Truncate MessageBox string if it is too long to not overflow the screen
* and cause possible oversized window error.
*/
-
-#define TK_MAX_WARN_LEN (1024 * sizeof(WCHAR))
- Tcl_UtfToExternalDString(unicodeEncoding, msg, -1, &msgString);
- Tcl_UtfToExternalDString(unicodeEncoding, title, -1, &titleString);
- if (Tcl_DStringLength(&msgString) > TK_MAX_WARN_LEN) {
- Tcl_DStringSetLength(&msgString, TK_MAX_WARN_LEN);
- Tcl_DStringAppend(&msgString, (char *) L" ...", 4 * sizeof(WCHAR));
- }
- MessageBoxW(NULL, (WCHAR *) Tcl_DStringValue(&msgString),
- (WCHAR *) Tcl_DStringValue(&titleString),
+ memcpy(msgString + TK_MAX_WARN_LEN, L" ...", 5 * sizeof(WCHAR));
+ titleString[TK_MAX_WARN_LEN] = L'\0';
+ MessageBoxW(NULL, msgString, titleString,
MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
| MB_SETFOREGROUND | MB_TOPMOST);
- Tcl_DStringFree(&msgString);
- Tcl_DStringFree(&titleString);
}
/*