Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling Title Bar's Close Window Icon

Status
Not open for further replies.

snake1411

Programmer
Aug 19, 2002
2
US
Is it possible to disable the close window (X) icon on the title bar of a window?

Thanks
 
Depends on what you mean by "disable." If you simply want it to do nothing when the user clicks on it, you can install a "do-nothing" protocol handler for WM_DELETE_WINDOW messages. (See my response to thread287-339303, "capture window's exit event," for more information.) For example, the following effectively disables the function of the close icon:

Code:
wm protocol . WM_DELETE_WINDOW {
  # Ignore the message
}

Note that the script can't be an empty string (that is, a 0-character-length string); that instructs Tcl to use its default handler, which is to destroy the window.

On the other hand, if you want to eliminate the "X" icon completely, that's a much more difficult project. Your only option in this case is to use wm overrideredirect to tell the window manager not to manage the window at all. This prevents the window manager from adding the titlebar to the window. It also prevents it from adding resize handles and other decorations. Overrideredirect windows are typically used only for splash screens and other transient windows. - Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Thank you for that solution. To anyone else who cares, this was exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top