diff options
Diffstat (limited to 'win/tkWinInit.c')
-rw-r--r-- | win/tkWinInit.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/win/tkWinInit.c b/win/tkWinInit.c index ab33607..19556dd 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -1,4 +1,4 @@ -/* +/* * tkWinInit.c -- * * This file contains Windows-specific interpreter initialization @@ -12,12 +12,6 @@ #include "tkWinInt.h" -/* - * The Init script (common to Windows and Unix platforms) is - * defined in tkInitScript.h - */ -#include "tkInitScript.h" - /* *---------------------------------------------------------------------- @@ -28,8 +22,8 @@ * tk_library variable. * * Results: - * A standard Tcl completion code (TCL_OK or TCL_ERROR). Also - * leaves information in the interp's result. + * A standard Tcl completion code (TCL_OK or TCL_ERROR). Also leaves + * information in the interp's result. * * Side effects: * Sets "tk_library" Tcl variable, runs "tk.tcl" script. @@ -38,15 +32,16 @@ */ int -TkpInit(interp) - Tcl_Interp *interp; +TkpInit( + Tcl_Interp *interp) { /* * This is necessary for static initialization, and is ok otherwise * because TkWinXInit flips a static bit to do its work just once. */ + TkWinXInit(Tk_GetHINSTANCE()); - return Tcl_Eval(interp, initScript); + return TCL_OK; } /* @@ -54,9 +49,9 @@ TkpInit(interp) * * TkpGetAppName -- * - * Retrieves the name of the current application from a platform - * specific location. For Windows, the application name is the - * root of the tail of the path contained in the tcl variable argv0. + * Retrieves the name of the current application from a platform specific + * location. For Windows, the application name is the root of the tail of + * the path contained in the tcl variable argv0. * * Results: * Returns the application name in the given Tcl_DString. @@ -68,9 +63,9 @@ TkpInit(interp) */ void -TkpGetAppName(interp, namePtr) - Tcl_Interp *interp; - Tcl_DString *namePtr; /* A previously initialized Tcl_DString. */ +TkpGetAppName( + Tcl_Interp *interp, + Tcl_DString *namePtr) /* A previously initialized Tcl_DString. */ { int argc, namelength; CONST char **argv = NULL, *name, *p; @@ -104,8 +99,8 @@ TkpGetAppName(interp, namePtr) * * TkpDisplayWarning -- * - * This routines is called from Tk_Main to display warning - * messages that occur during startup. + * This routines is called from Tk_Main to display warning messages that + * occur during startup. * * Results: * None. @@ -117,28 +112,31 @@ TkpGetAppName(interp, namePtr) */ void -TkpDisplayWarning(msg, title) - CONST char *msg; /* Message to be displayed. */ - CONST char *title; /* Title of warning. */ +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. + * 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); } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ |