Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!hp-pcd!hpcvlx!dex From: dex@hpcvlx.cv.hp.com (Dex Smith) Newsgroups: comp.windows.x Subject: Re: WM_DELETE and the Shell Widget Message-ID: <100920264@hpcvlx.cv.hp.com> Date: 19 Dec 90 16:26:39 GMT References: <224@ebt-inc.UUCP> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 38 In Motif, the VendorShell widget class (which is used by application shells) defines an XmNdeleteResponse resource. The default value for this resource is XmDESTORY. So, when the window receives a WM_DELETE_WINDOW message (ie. window manager Close command), the shell is destroyed. If it is the application's top-level shell, the process terminates. To "trap" the window manager Close command, you do two things: 1. Set the top-level shell's "deleteResponse" resource to XmDO_NOTHING: ac = 0; XtSetArg (al[ac], XmNdeletResponse, XmDO_NOTHING); ac++; XtSetValues (toplevel, al, ac); 2. Add a window manager protocol callback to detect when the shell gets the WM_DELETE_WINDOW message: Atom XaWmDelete; XaWmDelete= XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback(toplevel, XaWmDelete, MenuCB, MENU_File_Exit); This example code sets the callback to call a MenuCB() callback routine with an application-specific defined client_data of MENU_File_Exit. Presumably, this is the same callback and client_data used for the Exit command in the application's File menu. (That is, the window manager's Close command is now equivalent to the Exit command in the File menu.) I hope this helps! - Dex Smith, Learning Products Developer Interface Technology Operation Hewlett-Packard Company Corvallis, Oregon dex@hpcvlx.cv.hp.com