Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!haven.umd.edu!uflorida!mlb.semi.harris.com!sloth.mlb.semi.harris.com!pjp From: pjp@sloth.mlb.semi.harris.com (Pat J. Pinchera) Newsgroups: comp.windows.x.motif Subject: Dialog Unmap/'Close' Question and Problem -REVISITED- Keywords: UnmapCallbacks, Dialogs, Window Menu Button Message-ID: <1991May3.175805.27038@mlb.semi.harris.com> Date: 3 May 91 17:58:05 GMT Sender: pjp@mlb.semi.harris.com Followup-To: comp.windows.x.motif Organization: Interface & Control Systems, Inc. Lines: 55 Nntp-Posting-Host: sloth.mlb.semi.harris.com Dialog Unmap/'Close' Question: Note: this a repost of a problem that I had a couple of months ago. A working solution is proposed below. When I create 3 Form dialogs, with the hierarchy described below, I attach UnmapCallbacks to them which take care of some cleaning up for each window when it is unmapped. This callback is activated when I select the 'Close' option (Alt+F4) from the Window Menu Button (the 'Dash' button in the upper left corner of each window). The problem is when I 'Close' a dialog that has 1 or more children dialogs, (i.e. "dialog1" or "dialog2"); the UnmapCallback *DOES NOT GET CALLED* for the children dialogs, even though they disappear. For example, 'Close' dialog2, then dialog2 & dialog3 disappear, and dialog2 UnmapCallback gets called but dialog3 UnmapCallback does *NOT*. I tried the DestroyCallback, but that doesn't seem to get activated for the children either. +---------+ | dialog1 | | +---------+ Widget Hierarchy: | | dialog2 | dialog1 is parent of dialog2 | | +---------+ dialog2 is parent of dialog3 | | | dialog3 | +-| | | | | | +-| | | | +---------+ What can I do so that the children callbacks get activated as well, even though I didn't explicitly 'Close' them? (They need to do some cleaning up too!) I did receive one reply telling me to try XmAddWMProtocolCallback, and check the WM_DELETE_WINDOW protocol. Well I tried several combinations of this, but to no avail. However, I did find a working solution to my problem: Add a destroy callback to each dialog that contains all of the "clean-up actions" that you want to take place. Also attach an unmap callback to each dialog, and in it, only have the statement 'XtDestroyWidget(w)', where w is the widget passed to the callback. What results is the unmap callback gets called, destroys the widget that you 'closed', and as a result, destroys the children widgets. Since we've attached a destroy callback, it gets called for each child dialog, and voila', clean-up actions take place for each dialog!!! If you see any problems with the implementation, OR have a better, more efficient, or more portable method, please respond. I'm not particularly proud of this solution, but hey, it *does* work. Patrick Pinchera Interface & Control Systems, Inc. Melbourne, FL