Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Closing several open child windows

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Closing several open child windows
#7273
Posted by: misi01 2005-10-20 18:08:02
The scenario is as follows. My main window layout script opens 2 child windows (ie, creates two child window layouts). None of the child windows are modal, and both are open/visible at the same time. I close my main window and my main script ends. I see that the child windows automatically close (along with the main window). This is the behavior I want.

Now assume I call GuiDestroyWindow on my main window, but don't end the main window layout script. The two child windows remain open (until my main script finally ends). How do I close those 2 windows when I close my main window?
Michael
Message2. Re: Multiple open child windows
#7275
Posted by: Jeff Glatt 2005-10-20 18:21:47
You have two choices.

1) Make your main window the parent of each child window, and they'll all automatically close down when your main window closes.

2) Add a CLOSE event handler for your main window, and in that event handler, DROP the two child objects (if you want to close their windows, and unload their variables from memory), or call their DestroyWindow functions (if you just want to close their windows without unloaded their variables).
Message3. Re: Multiple open child windows
#7343
Posted by: misi01 2005-10-24 17:39:35
Okay. I'm trying to understand what coding I need to ensure that closing windows (main ones with or without children) via a cancel button (rather than top right-hand corner) will ALWAYS work (seeing as how I've been having problems with this).

For example. The standard generated main window script is as follows (comments removed)

again:
DO FOREVER
  guigetmsg()
  IF EXISTS('GuiObject') == 0 THEN DO
    IF EXISTS('GuiSignal') THEN DO
     /* One of our handlers below called GuiWake() to tell us to do something here. */
    END
  END
Assuming (as I mentioned above) that I've added an event handler for any push buttons, is there any real reason to include code to handle these buttons in the code above ?

This is why, originally, I included code that, for a cancel button, included a GUIWAKE('CLOSE') and then (in the code above) determined that GUISIGNAL was 'CLOSE' and therefore left the loop.
Now, you've shown that I should use the guisendmsg(,'POST CLOSE') instead, the idea of needing code to test things from the main window disappears. Another example.
Originally, I might have had (for the OK button) code such as

again:
DO FOREVER
  guigetmsg()
  IF EXISTS('GuiObject') == 0 THEN DO
    IF EXISTS('GuiSignal') THEN DO
      SELECT guisignal
        WHEN 'OK' THEN
          CALL perform_whatever_we_want_to_do()
        OTHERWISE
      END
    END
  END
Now, instead of doing a guiwake('OK') in the event handler for the OK button, I simply replace that with call perform_whatever_we_want_to_do().

For this reason, the idea of needing any code in the main loop for push buttons on the main window disappears more and more.



Michael
Message4. Re: Multiple open child windows
#7344
Posted by: Jeff Glatt 2005-10-24 18:57:11
You don't normally need to inform your (main script's) message loop that an event happened for one of the controls in your main window. Typically, the event handler will do whatever it needs to do.

GuiWake() is intended mostly for some event handler in a child window (script) to tell its parent script to do something (or to pass data back to the parent script). Using GuiWake(), the parent script will wake up from GuiGetMsg (after the child's handler finally returns). Reginald will have set the GuiObject and GuiSignal variables in the parent script. And then the parent script should do whatever it was told to do.




GuiWake is mostly just a wrapper around GuiSendMsg(). It sends a proprietary message number to the parent window. REXX GUI handles some stuff for you, such as setting the GuiSignal and GuiObject variables in the main script.

But for standard things such as closing a window, there are already standard message numbers defined by the operating system. So you can simply call GuiSendMsg yourself, for example to send the "CLOSE" message to a window. In this case, you'll cause REXX GUI to invoke the appropriate event handler for that window. (Or, if the window isn't handling that event, REXX GUI does the default handling).
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0