Silverfrost Forums

Welcome to our forums

If button in one window opens second window, can I use both?

24 Oct 2011 9:33 #9125

The question is somewhat related to the other question I just posted in this forum.

I have a program that opens a window. In that window are a number of controls. One of them is a button which, when clicked, opens a second window elsewhere on the screen, that also has a number of controls of its own.

I've noticed that, after the second window is open, I can no longer access any of the controls in the first window, I can only use the controls in the second window. Not until I close the second window, does the first window 'come alive' again and I can use its controls.

Is there a way I can use the controls in BOTH windows, while both are open?

This short program illustrates what I mean:

[color=green:895fcd4a80]

  PROGRAM   MyMainProg
  WINAPP
  INCLUDE <windows.ins>

C**********************************************************************

  CALL OpenFirstWin

  STOP
  END

C C SUBROUTINE OpenFirstWin() INTEGER Open2ndWinCallbk EXTERNAL Open2ndWinCallbk C* Position the First Window on screen. i=winio@('%sp&',20,20) C* Create the First Window. i=winio@('%ca[This is the first window]&') C C* Put short description in First Window. i=winio@('%ap&amp;',5.0D0,3.0D0) i=winio@('%25rs&','Short Descr. inside First Window') C* Put 'Open Second Window' button i=winio@('%`ap&',10.0D0,8.0D0) C* No ampersand so that first window opens after this statement. i=winio@('%^bt[Open Second Window]',Open2ndWinCallbk)

  RETURN
  END

C C INTEGER FUNCTION Open2ndWinCallbk() INTEGER DoNothingCallBk DOUBLE PRECISION DX,DY EXTERNAL DoNothingCallBk C C* Position the Second Window somewhere else on screen. DX=RANDOM@()500.0+100.0 DY=RANDOM@()400.0+100.0 IX=DX IY=DY i=winio@('%sp&',IX,IY) C Create the Second Window. i=winio@('%ca[This is the Second Window]&') C C Put short description. i=winio@('%ap&amp;',5.0D0,5.0D0) i=winio@('%25rs&','Short Descr. inside 2nd Win') C* Put small 'Do Nothing' button i=winio@('%`ap&',10.0D0,12.0D0) C* No ampersand so that second window opens after this statement. i=winio@('%^bt[This Button Does Nothing]',DoNothingCallBk) Open2ndWinCallbk=1 END C C INTEGER FUNCTION DoNothingCallbk() C DoNothingCallbk=1 END
[/color:895fcd4a80]

25 Oct 2011 10:39 #9128

Yes, you can. Finish the winio of the first window using:-

winio@(‘%lw[option]’, ctrl) integer ctrl (output)

See the help file to explain how to use it.

25 Oct 2011 7:56 #9129

Hmmm, the use of %lw doesn't seem to change much.

The %lw function is obviously used to 'leave a window open', hence the letters after the percent. But my windows were already staying open. The problem was, I could only do things with the last-opened window, but cannot do anything (click a button etc.) in the window that was opened first.

Maybe I phrased my question poorly?

I've included the %lw function in the following (simplified) program. Also placed the control variables in a COMMON block because I have a hunch I'll need them, though I don't use them here.

When you start the program, it opens a first window near the upper left corner of the screen, with three buttons in it. The buttons will open a small red window, small blue window, and small green window respectively.

When you click the first button, it will open a red window in another part of the screen (the red window has no button).

At that point I'd like to go back to the first window, and click the second button to open a blue window. Butthe system won't let me go back to the first window - it beeps, and flashes the second (red) window at me, apparently saying that the second window is the ONLY one I can do anything with. Only after I close the second (red) window, does the system let me go back to the first window and either click another button, or close it.

How can I modify the simple program below, so that I can start the program, click the first button in the first window to create a red window, and then click the second button to creat a blue window, and then click the third button to create a green window... all without closing the red or blue windows?

And, while the red, blue, and green windows are still open, how can I go back to the first window and close it, and have the red, blue, and green windows all close automatically at the same time?


[color=blue:db135add84]

  PROGRAM   MyMainProg
  WINAPP
  INCLUDE <windows.ins>
  COMMON/WinCtls/Icont1,IContRed,IContBlue,IContGreen
  CALL OpenFirstWin
  STOP
  END

  SUBROUTINE OpenFirstWin()
  INTEGER OpenRedWinCallbk,OpenBlueWinCallbk,OpenGreenWinCallbk
  EXTERNAL OpenRedWinCallbk,OpenBlueWinCallbk,OpenGreenWinCallbk
  COMMON/WinCtls/Icont1,IContRed,IContBlue,IContGreen

C* Position the First Window on screen. i=winio@('%sp&',20,20) i=winio@('Message in 1st window%ca[This is the first window]&') C* Put three buttons in first window, to open various second windows. i=winio@('%2nl%^bt[Open Red Window]%2nl&',OpenRedWinCallbk) i=winio@('%^bt[Open Blue Window]%2nl&',OpenBlueWinCallbk) i=winio@('%^bt[Open Green Window]&',OpenGreenWinCallbk) i=winio@('%lw[owned]',Icont1) RETURN END

  INTEGER FUNCTION OpenRedWinCallbk()
  COMMON/WinCtls/Icont1,IContRed,IContBlue,IContGreen
  i=winio@('%sp&amp;',200,300)
  i=winio@('Message in Red window %ca[This is the Red Window]&amp;')
  i=winio@('%bg[red]%lw[owned]',IcontRed)
  OpenRedWinCallbk=1
  END

  INTEGER FUNCTION OpenBlueWinCallbk()
  COMMON/WinCtls/Icont1,IContRed,IContBlue,IContGreen
  i=winio@('%sp&amp;',250,400)
  i=winio@('Message in Blue window %ca[This is the Blue Window]&amp;')
  i=winio@('%bg[blue]%lw[owned]',IcontBlue)
  OpenBlueWinCallbk=1
  END

  INTEGER FUNCTION OpenGreenWinCallbk()
  COMMON/WinCtls/Icont1,IContRed,IContBlue,IContGreen
  i=winio@('%sp&amp;',300,500)
  i=winio@('Message in Green window %ca[This is the Green Window]&amp;')
  i=winio@('%bg[green]%lw[owned]',IcontGreen)
  OpenGreenWinCallbk=1
  END

[/color:db135add84]

26 Oct 2011 5:46 #9130

You should add %ww to each 'colour' window:

PROGRAM MyMainProg 
WINAPP
INCLUDE <windows.ins> 
INTEGER*4  OpenRedWinCallbk,OpenBlueWinCallbk,OpenGreenWinCallbk 
EXTERNAL OpenRedWinCallbk,OpenBlueWinCallbk,OpenGreenWinCallbk 
COMMON/WinCtls/Icont1
icont1 = -1
i=winio@('%ca[This is the first window]%sp&',20L,20L) 
i=winio@('%^bt[Open Red Window]%2nl&',OpenRedWinCallbk) 
i=winio@('%^bt[Open Blue Window]%2nl&',OpenBlueWinCallbk) 
i=winio@('%^bt[Open Green Window]%2nl&',OpenGreenWinCallbk) 
i=winio@('%^bt[Exit]','+','set',icont1,0L,'EXIT')
END 

INTEGER FUNCTION OpenRedWinCallbk()
COMMON/WinCtls/Icont1
i=winio@('%ca[This is the Red Window]%ww[topmost]%sp&',200L,300L) 
i=winio@('%bg[red]%lw',Icont1) 
OpenRedWinCallbk=2
END 

INTEGER FUNCTION OpenBlueWinCallbk() 
COMMON/WinCtls/Icont1
i=winio@('%ca[This is the Blue Window]%ww[topmost]%sp&',250L,400L) 
i=winio@('%bg[blue]%lw',Icont1) 
OpenBlueWinCallbk=2
END 

INTEGER FUNCTION OpenGreenWinCallbk() 
COMMON/WinCtls/Icont1
i=winio@('%ca[This is the Green Window]%ww[topmost]%sp&',300L,500L) 
i=winio@('%bg[green]%lw',Icont1) 
OpenGreenWinCallbk=2
END

Regards - Wilfried

26 Oct 2011 7:04 #9132

GREAT!!! It worked!!!

Thank you so much, Wilfried!

Please login to reply.