diff options
author | hobbs <hobbs> | 2003-02-18 19:18:29 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-02-18 19:18:29 (GMT) |
commit | 037bdae6bab0c2729a13c3a8936c815f067b3dde (patch) | |
tree | 1b39a95ac9ff5c18fe6f113c3838b3d27bf13536 | |
parent | abf069b7b02a9c336e9ab34d8fa3a7220051bc1a (diff) | |
download | tk-037bdae6bab0c2729a13c3a8936c815f067b3dde.zip tk-037bdae6bab0c2729a13c3a8936c815f067b3dde.tar.gz tk-037bdae6bab0c2729a13c3a8936c815f067b3dde.tar.bz2 |
* win/tkWinInit.c (TkpDisplayWarning): truncate MessageBox string
to 1024 chars to prevent possible oversized window errors. May be
necessary in other MB uses (ie Tcl_AppInit). [Tcl Bug #608559]
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | win/tkWinInit.c | 11 |
2 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,9 @@ +2003-02-18 Jeff Hobbs <jeffh@ActiveState.com> + + * win/tkWinInit.c (TkpDisplayWarning): truncate MessageBox string + to 1024 chars to prevent possible oversized window errors. May be + necessary in other MB uses (ie Tcl_AppInit). [Tcl Bug #608559] + 2003-02-18 Vince Darley <vincentdarley@users.sourceforge.net> * macosx/tkMacOSXMenu.c: (SetMenuTitle) fix to utf encoding diff --git a/win/tkWinInit.c b/win/tkWinInit.c index 1ec2642..bdedb2b 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.10 2002/12/08 00:46:51 hobbs Exp $ + * RCS: @(#) $Id: tkWinInit.c,v 1.11 2003/02/18 19:18:33 hobbs Exp $ */ #include "tkWinInt.h" @@ -126,8 +126,17 @@ TkpDisplayWarning(msg, title) Tcl_DString msgString, titleString; Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding(); + /* + * 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), MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL |