April 26, 2024, 06:16:08 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Creating Child Windows

Started by GWS, January 24, 2012, 06:17:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi,

Creating child windows in Creative Basic is easy.

Create a main window (there's no need to use the @MDIFRAME parameter) as the parent window.

For all other child windows, use the parent windows variable as the 'parent' parameter of the window.


' Program demonstrating a simple (non-MDI) main/child window arrangement.
' GWS - 2012

def main,child:WINDOW

window main,0,0,500,300,@MINBOX|@MAXBOX|@SIZE,0,"MainWindow",mainhandler
window child,0,0,200,100,@SIZE,main,"Child Window",childhandler

setwindowcolor main,0xff8800
setwindowcolor child,0xaa6666
centerwindow main
centerwindow child

run = 1

waituntil run = 0
closewindow main :' Note: this also closes any remaining child windows
end

mainhandler:
SELECT @CLASS
case @IDCLOSEWINDOW
run = 0
ENDSELECT
RETURN

childhandler:
SELECT @CLASS
case @IDCLOSEWINDOW
closewindow child
ENDSELECT
RETURN


Now the child window remains on top of the parent.  This is good for things like tool windows, information  boxes, etc.

If the main window is closed, all child windows are also closed.

all the best, :)

Graham
Tomorrow may be too late ..

tbohon

Nicely done, Graham ... thanks!
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

GWS

Tomorrow may be too late ..