Under Windows, Tk complains when using an external widget (via -use) and raises a dialog to allow the user to use/abandon the usage. This may be fine for the general case, but it is useless when Tk is used via th eTcl plugin. I am currently working on a massive update of the tcl plugin using TclTk 8.5.13+ in latest firefix/chromium/... browsers and this dialog is annoying. Here is a patch to fix the behaviour in win/tkWinEmbed.c:TkpUseWindow that avoids to open the dialog when Tk is run inside the plugin. The test is simple but works fine.
if (id == PTR2INT(hwnd)) {
if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
Tcl_AppendResult(interp, "The container is already in use", NULL);
return TCL_ERROR;
}
} else if (id == -PTR2INT(hwnd)) {
Tcl_AppendResult(interp, "the window to use is not a Tk container",
NULL);
return TCL_ERROR;
} else {
/* wke: perform check only when not in plugin! */
if(!Tcl_GetVar2(interp,"plugin","patchLevel",TCL_GLOBAL_ONLY)) {
/*
* Proceed if the user decide to do so because it can be a legacy
* container application. However we may have to return a TCL_ERROR in
* order to avoid bug 1096074 in future.
*/
char msg[256];
sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string);
if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning",
MB_OKCANCEL | MB_ICONWARNING)) {
Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC);
return TCL_ERROR;
}
}
}
Patched tkWinEmbed.c without dialog when using non-Tk external window.