Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Window not being brought to the fore

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

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Window not being brought to the fore
#7296
Posted by: misi01 2005-10-21 19:23:33
This certainly seems to be a bug. 3 scripts, first main_test1

/*
GUIBEGIN
WINDOW , 0, 0, 142, 71, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , My Window
	FONT 8, 400, MS Shell Dlg
	PUSH 20, 24, 97, 14, TABSTOP, , start_child1_button, , Start child1
	PUSH 21, 45, 94, 14, TABSTOP, , start_child2_button, , Start child2
DEND
GUIEND
*/

LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
  guigetmsg()
  IF EXISTS('GuiObject') \== 0 THEN DO
    IF EXISTS('GuiSignal') == 0 THEN DROP (guiobject)
  END
  CATCH SYNTAX
    CONDITION('M')
    SIGNAL again
  CATCH HALT
  FINALLY
    guidestroywindow()
END
RETURN

wm_click_start_child1_button:
  arg_string.0 = 1
  arg_string.1 = 'This is the first line'
  createobject("main_child1.rex", 'child1.')
  RETURN

wm_click_start_child2_button:
  arg_string.0 = 1
  arg_string.1 = 'This is the first line'
  createobject("main_child2.rex", 'child2.', ,guiwindow, arg_string., 0, 'My title for main child2')
  RETURN

and now main_child2

/*
GUIBEGIN
WINDOW , 58, 41, 176, 109, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Child2
	FONT 8, 400, MS Shell Dlg
	ENTRY 8, 10, 111, 90, MULTI|H_AUTO|BORDER|TABSTOP, , arg_string
	PUSH 126, 82, 40, 14, TABSTOP, , ok_button, , OK
DEND
GUIEND
*/

create:
  USE ARG parent_window, arg_string., modal, title
  guierr = "SYNTAX"
  guiheading = 1
  IF modal = 0 THEN modal = ''

createwindow:
  IF modal = '' THEN
    guicreatewindow('HIDE', parent_window)
  ELSE
    guicreatewindow('HIDE', -1) 

  IF title \= '' THEN
    guiaddctltext(, title)

  guisetctlvalue()

  guisetctlplacement(,,,,,,'NORMAL')
  RETURN

destroywindow:
destroy:
  guidestroywindow()
  RETURN

wm_click_ok_button:
  guisay('Clicked on OK button')
  RETURN
finally, main_child1.

/*
GUIBEGIN
WINDOW , 12, 48, 176, 109, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Child1
	FONT 8, 400, MS Shell Dlg
	ENTRY 8, 10, 111, 90, H_AUTO|BORDER|TABSTOP, , arg_string
	PUSH 126, 82, 40, 14, TABSTOP, , ok_button, , OK
DEND
GUIEND
*/

create:
  USE ARG arg_string.
  guierr = "SYNTAX"
  guiheading = 1
createwindow:
  guicreatewindow('SHOW')
  RETURN

destroywindow:
destroy:
  guidestroywindow()
  RETURN

wm_click_ok_button:
  guisay('Clicked on OK button')
  RETURN
Start RPC, open main_test1 and run it. Select "Start child2".

Notice how if you put focus on the main window it isn't brought to the fore. Move child2 out of the way and select child1. Now put focus on the main window -this time it WILL be brought to the fore.

It seems to be something to do with passing the handle for the main window. If you change the line in main_test1 from
createobject("main_child1.rex", 'child1.')
to
createobject("main_child1.rex", 'child1.' , ,guiwindow)
then child1 will behave the same way as child2.
Michael
Message2. Re: Window not being brought to the fore
#7357
Posted by: Jeff Glatt 2005-10-27 16:09:55
I believe that this is Windows default behavior. When you make a window a child of some other window, it remains above its parent window.
Message3. Re: Window not being brought to the fore
#7358
Posted by: misi01 2005-10-27 17:24:31
Now that you mention that, I can see the difference inasmuch as, if I call guicreatewindow in the child script with a second argument (parent window handle), then the main window never "overlays" the child". If I call it WITHOUT that parm, it can overlay it (which is basically what you're saying).

That being the case, please recap HOW I would solve the following potential problem.

Assume I start a couple of windows from my main window WITHOUT the guiwindow handle being passed from the parent, so that I can have all 3 windows open at the same time.
Now assume I close the main window and want to ensure that the other two are also closed. You've explained to me before that as long as I start the 2 secondary windows with the main window's handle, they will AUTOMATICALLY be closed when the main window is closed. How do I GUARANTEE the same situation if they're NOT created using the main window's handle ?
Michael
Message4. Re: Window not being brought to the fore
#7366
Posted by: Jeff Glatt 2005-10-28 01:04:18
Easiest: Add a "CLOSE" event handler for the main window. In that handler, DROP the variable for each child. (After your CLOSE event handler returns, your main script subsequently will call GuiGetMsg and return immediately, with GuiObject set to the first child you drop'ed, and GuiSignal DROP'ed. Your main script will typically DROP that particular child a second time, which is harmless. DROP'ing an object that has already been DROP'ed does nothing).

Alternately, if you happen to have a child window's handle, you can call GuiSendMsg to send it a "CLOSE" message:
guisendmsg(mychildwindowhandle, "POST CLOSE")
In that case, when your main window's CLOSE handler returns, you'll resume your message loop, and a series of calls to GuiGetMsg will result in each child's window being destroyed, with GuiObject set to that child object, and GuiSignal DROP'ed. Your message loop will DROP each child, as usual.

NOTE: With the second approach, the main window will actually be destroyed before the child windows. In the first approach, it's the opposite.
Message5. Re: Window not being brought to the fore
#7368
Posted by: Michael S 2005-10-28 02:08:57
Okay - I'm thick.
DROP the variable for each child.
If I perform (from the main window) a

createobject('child_wdw_n_rex', 'childn.')

do I simply

DROP (childn.)
???
Message6. Re: Window not being brought to the fore
#7370
Posted by: Jeff Glatt 2005-10-28 02:18:28
No, you're specifying the variable name directly to DROP, so no parentheses:
DROP childn.
Whereas...
DROP (guiobject)
...is saying "Don't drop the variable GUIOBJECT, but rather, DROP the variable whose name is stored in GUIOBJECT".
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-2-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0