Index: win/tkWinInit.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinInit.c,v
retrieving revision 1.17
diff -u -r1.17 tkWinInit.c
--- win/tkWinInit.c	24 Nov 2010 10:34:18 -0000	1.17
+++ win/tkWinInit.c	16 Dec 2010 12:59:18 -0000
@@ -118,21 +118,32 @@
     const char *msg,		/* Message to be displayed. */
     const char *title)		/* Title of warning. */
 {
-#define TK_MAX_WARN_LEN 1024
-    WCHAR msgString[TK_MAX_WARN_LEN + 5];
-    WCHAR titleString[TK_MAX_WARN_LEN + 1];
+#define TK_MAX_WARN_LEN 14
+    WCHAR titleString[TK_MAX_WARN_LEN];
+    WCHAR *msgString; /* points to titleString, just after title, leaving space for ": " */
+    int len; /* size of title, including terminating NULL */
 
-    MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, TK_MAX_WARN_LEN);
-    MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
+    len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
+    msgString = &titleString[len + 1];
+    titleString[TK_MAX_WARN_LEN - 1] = L'\0';
+    MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len);
     /*
      * Truncate MessageBox string if it is too long to not overflow the screen
      * and cause possible oversized window error.
      */
-	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);
+    if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') {
+	memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR));
+    }
+    if (IsDebuggerPresent()) {
+	titleString[len - 1] = L':';
+	titleString[len] = L' ';
+	OutputDebugStringW(titleString);
+    } else {
+	titleString[len - 1] = L'\0';
+	MessageBoxW(NULL, msgString, titleString,
+		MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
+		| MB_SETFOREGROUND | MB_TOPMOST);
+    }
 }
 
 /*
