Title Simulated MDI Example in VDS
DIALOG CREATE,Simulated MDI Example,1,0,423,58
DIALOG ADD,BITBTN,NEW,14,12,32,32,C:\Program Files\Visual DialogScript\icons\toolbar\New.bmp,,Create new document
DIALOG ADD,TEXT,TEXT1,6,56,360,48,This is an example of how to create a Simulated Multi-Document-Interface in VDS. Since VDS does not support true creation of an MDI it is necessary for us to SIMULATE it. Click the button opposite to create a new window
DIALOG SHOW

:evloop
wait event
%Z = @event(D)
rem Note the "D" used in the @event(). The D tells VDS that we wish to know 
rem the ID of the dialog which caused the event. VDS returns the information 
rem in the format EVENT|ID

parse "%Y;%W", %Z
rem We use the parse command to insert the event into %Y and the dialog ID 
rem into %W

if @EQUAL(%W,0)
goto %Y
ELSE
goto %Y_DOCUMENT
rem If the event was caused by a MDI document we append "_DOCUMENT" this is
rem for our own benefit, it makes things easier to read, and we avoid 
rem complicated use of DIALOG CLOSE etc..

:RESIZE
goto evloop

:NEWBUTTON
%%ID = @SUCC(%%ID)
DIALOG CREATE,MDI Document - No %%ID,-1,0,426,158
DIALOG ADD,GROUP,GROUP,72,106,198,82,Change the levels:
DIALOG ADD,EDIT,EDIT1,2,0,426,66,This is a MDI Document. You are able to open multiple instances of this document and each one will be independant of the other! Mess with the elements below"," only the data in THIS window will change!,MULTI,WRAP,SCROLL
DIALOG ADD,RADIO,CHOICE,72,4,96,82,My Choice,Info 1|Info 2,,CLICK
DIALOG ADD,TRACKBAR,LEVEL,92,110,186,30,,10,,CLICK
DIALOG ADD,PROGRESS,PROGRESS,124,118,166,24
DIALOG ADD,CHECK,CHECK1,78,320,148,18,Check Me
DIALOG ADD,CHECK,CHECK2,104,320,148,18,No Me
DIALOG ADD,CHECK,CHECK3,130,320,148,18,Why not me?
DIALOG SHOW
goto evloop

:CHOICECLICK_DOCUMENT
rem This function serves the purpose of ALL documents. But when it acts upon
rem what has been clicked the changes it makes only affect the MDI Document
rem that the event came from.
if @EQUAL(@DLGTEXT(CHOICE),Info 1)
DIALOG SET,EDIT1,You have selected Info 1. Now load up another MDI document and you will see that any changes you have made here will no affect any other windows!
ELSE
DIALOG SET,EDIT1,You have selected Info 2. I'm sure you can see the benefits of MDI. Try experimenting yourself. There is a lot more that can be done!
END
goto evloop

:LEVELCLICK_DOCUMENT
DIALOG SET,PROGRESS,@DLGTEXT(LEVEL)
goto evloop
rem Again this function is called by every MDI document, but when it changes
rem the level of the progress bar it only affects the one on the document
rem that generated the event!


:Close_DOCUMENT
DIALOG SELECT,%W
DIALOG CLOSE
%%BIN = @event()

rem This is a MDI function (note the "_DOCUMENT") it closes the MDI window
rem thanks to the @event(D) we are able to tell which window to close based
rem on what window the user attempted to close
goto evloop

:Close
rem This is the main close function. This exits from the program completely!
exit
