OriginalBugID: 602 RFE
Version: 8.0p2
SubmitDate: '1998-05-21'
LastModified: '2000-06-19'
Severity: LOW
Status: Assigned
Submitter: hershey
ChangedBy: ericm
RelatedBugIDs: 2589 5496
OS: All Windows
FixedInVersion: NA
The tk_messageBox library procedure in Tk8.0p2 is essentially an
interface to the Windows MessageBox function.
However, one of the important settings for MessageBox, the modality,
can not be controlled using tk_messageBox. Instead, in Tk8.0p2, all
MessageBox calls use MB_SYSTEMMODAL.
The appended patch adds a -modal parameter to tk_messageBox. On Unix
and the Mac, the extra parameter is simply ignored. On Windows, it
may used to set the modality correctly. If the new -modal parameter
is not used, the default remains MB_SYSTEMMODAL, as before.
I did not update the documentation for this patch.
Ian Taylor
ian@cygnus.com
*** /5g/ian/tk8.0p2/library/msgbox.tcl Mon Aug 4 13:38:04 1997
--- library/msgbox.tcl Thu Apr 16 15:31:46 1998
*************** proc tkMessageBox {args} {
*** 41,46 ****
--- 41,47 ----
{-default "" "" ""}
{-icon "" "" "info"}
{-message "" "" ""}
+ {-modal "" "" ""}
{-parent "" "" .}
{-title "" "" " "}
{-type "" "" "ok"}
*** /5g/ian/tk8.0p2/tests/msgbox.test Mon Aug 4 13:37:58 1997
--- tests/msgbox.test Thu Apr 16 15:31:47 1998
*************** if {[string compare test [info procs tes
*** 15,24 ****
test msgbox-1.1 {tk_messageBox command} {
list [catch {tk_messageBox -foo} msg] $msg
! } {1 {unknown option "-foo", must be -default, -icon, -message, -parent, -title or -type}}
test msgbox-1.2 {tk_messageBox command} {
list [catch {tk_messageBox -foo bar} msg] $msg
! } {1 {unknown option "-foo", must be -default, -icon, -message, -parent, -title or -type}}
catch {tk_messageBox -foo bar} msg
regsub -all , $msg "" options
--- 15,24 ----
test msgbox-1.1 {tk_messageBox command} {
list [catch {tk_messageBox -foo} msg] $msg
! } {1 {unknown option "-foo", must be -default, -icon, -message, -modal, -parent, -title or -type}}
test msgbox-1.2 {tk_messageBox command} {
list [catch {tk_messageBox -foo bar} msg] $msg
! } {1 {unknown option "-foo", must be -default, -icon, -message, -modal, -parent, -title or -type}}
catch {tk_messageBox -foo bar} msg
regsub -all , $msg "" options
*** /5g/ian/tk8.0p2/win/tkWinDialog.c Tue Oct 28 11:37:34 1997
--- win/tkWinDialog.c Thu Apr 16 15:31:47 1998
*************** Tk_MessageBoxCmd(clientData, interp, arg
*** 826,837 ****
char **argv; /* Argument strings. */
{
int flags;
! Tk_Window parent = Tk_MainWindow(interp);
HWND hWnd;
char *message = "";
char *title = "";
int icon = MB_ICONINFORMATION;
int type = MB_OK;
int i, j;
char *result;
int code, oldMode;
--- 826,838 ----
char **argv; /* Argument strings. */
{
int flags;
! Tk_Window parent = NULL;
HWND hWnd;
char *message = "";
char *title = "";
int icon = MB_ICONINFORMATION;
int type = MB_OK;
+ int modal = MB_SYSTEMMODAL;
int i, j;
char *result;
int code, oldMode;
*************** Tk_MessageBoxCmd(clientData, interp, arg
*** 905,910 ****
--- 906,929 ----
return TCL_ERROR;
}
}
+ else if (strncmp (argv[i], "-modal", len) == 0) {
+ if (v==argc) {goto arg_missing;}
+
+ if (strcmp(argv[v], "system") == 0) {
+ modal = MB_SYSTEMMODAL;
+ }
+ else if (strcmp(argv[v], "task") == 0) {
+ modal = MB_TASKMODAL;
+ }
+ else if (strcmp(argv[v], "owner") == 0) {
+ modal = MB_APPLMODAL;
+ }
+ else {
+ Tcl_AppendResult(interp, "invalid modality \"", argv[v],
+ "\", must be system, task or owner", NULL);
+ return TCL_ERROR;
+ }
+ }
else {
Tcl_AppendResult(interp, "unknown option \"",
argv[i], "\", must be -default, -icon, ",
*************** Tk_MessageBoxCmd(clientData, interp, arg
*** 915,924 ****
/* Make sure we have a valid hWnd to act as the parent of this message box
*/
! if (Tk_WindowId(parent) == None) {
! Tk_MakeWindowExist(parent);
}
- hWnd = Tk_GetHWND(Tk_WindowId(parent));
if (defaultBtn != NULL) {
for (i=0; i<NUM_TYPES; i++) {
--- 934,951 ----
/* Make sure we have a valid hWnd to act as the parent of this message box
*/
! if (parent == NULL && modal == MB_TASKMODAL) {
! hWnd = NULL;
! }
! else {
! if (parent == NULL) {
! parent = Tk_MainWindow(interp);
! }
! if (Tk_WindowId(parent) == None) {
! Tk_MakeWindowExist(parent);
! }
! hWnd = Tk_GetHWND(Tk_WindowId(parent));
}
if (defaultBtn != NULL) {
for (i=0; i<NUM_TYPES; i++) {
*************** Tk_MessageBoxCmd(clientData, interp, arg
*** 950,956 ****
flags |= icon | type;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
! code = MessageBox(hWnd, message, title, flags|MB_SYSTEMMODAL);
(void) Tcl_SetServiceMode(oldMode);
switch (code) {
--- 977,983 ----
flags |= icon | type;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
! code = MessageBox(hWnd, message, title, flags|modal);
(void) Tcl_SetServiceMode(oldMode);
switch (code) {
It seems that making this change has no effect on how events are
actually handled on NT. No matter what modal I use, Windows only
seems to make the parent locked out.
-- 01/29/2000 hobbs
It would be best if some definition of the -modal flag could be found for the UNIX and Macintosh as well. This may just mean changing the grab from local to global for that particular dialog. It's not good to have "no-op" flags for a platform independant command like this.
- eric
-- 06/19/2000 ericm
Logged In: YES
user_id=79902
Haven't you done something like this with [wm attributes], Jeff?