DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sun Jun 10, 2007 1:39 pm Post subject: DialogID demo - Keeping track of multiple dialogs |
|
|
Here's a simple demonstration of using Trapper's DialogID function and command to keep track of multiple dialogs.
Trapper's post can be seen here: http://www.vdsworld.com/forum/viewtopic.php?p=27138#27138
Code: |
# Idea from Trapper: http://www.vdsworld.com/forum/viewtopic.php?p=27138#27138
# Demo by DaveŽ 10-June-2007
# Needed for DialogID function and command
#define command,DialogID
#define function,DialogID
# Needed for DialogID function and command
%%DialogIDList = 1
list create,%%DialogIDList
# Main dialog with class - Class needed for DialogID function and command
DIALOG CREATE,Main Dialog,145,350,340,260,CLASS Main,ontop
DIALOG ADD,BUTTON,child1open,42,56,95,24,Open Child 1
DIALOG ADD,BUTTON,child2open,74,56,95,24,Open Child 2
DIALOG ADD,BUTTON,child3open,106,56,95,24,Open Child 3
DIALOG ADD,BUTTON,child1_close,42,184,95,24,Close Child 1
DIALOG ADD,BUTTON,child2_close,74,184,95,24,Close Child 2
DIALOG ADD,BUTTON,child3_close,106,184,95,24,Close Child 3
DIALOG ADD,BUTTON,Close,173,122,95,24,Close
DIALOG ADD,STATUS,STATUSmain,
DIALOG SHOW
# Needed for DialogID function and command
DialogID Add,Main
:evloop
gosub StatusSet
rem wait event,0.1
wait event
parse "%E;%D",@event(D)
# Needed for DialogID function and command
if @zero(%D)
dialog select,0
goto %E
else
dialog select,%D
goto @DialogID(%D)_%E
end
# Child open buttons
:child1openbutton
if @not(@winexists(#Child1))
# Child dialog with class - Class needed for DialogID function and command
DIALOG CREATE,Child 1 Dialog,450,140,240,160,CLASS Child1,ontop
DIALOG ADD,BUTTON,ID,40,77,80,24,Dialog ID
DIALOG ADD,BUTTON,close,72,77,80,24,Close Child 1
DIALOG ADD,STATUS,STATUSchild1,
DIALOG SHOW
# Needed for DialogID function and command
DialogID Add,Child1
end
goto evloop
:child2openbutton
if @not(@winexists(#Child2))
# Child dialog with class - Class needed for DialogID function and command
DIALOG CREATE,Child 2 Dialog,450,400,240,160,CLASS Child2,ontop
DIALOG ADD,BUTTON,ID,40,77,80,24,Dialog ID
DIALOG ADD,BUTTON,close,72,77,80,24,Close Child 2
DIALOG ADD,STATUS,STATUSchild2,
DIALOG SHOW
# Needed for DialogID function and command
DialogID Add,Child2
end
goto evloop
:child3openbutton
if @not(@winexists(#Child3))
# Child dialog with class - Class needed for DialogID function and command
DIALOG CREATE,Child 3 Dialog,450,660,240,160,CLASS Child3,ontop
DIALOG ADD,BUTTON,ID,40,77,80,24,Dialog ID
DIALOG ADD,BUTTON,close,72,77,80,24,Close Child 3
DIALOG ADD,STATUS,STATUSchild3,
DIALOG SHOW
# Needed for DialogID function and command
DialogID Add,Child3
end
goto evloop
# Close buttons
:close
:closebutton
stop
:child1_close
:child1_closebutton
if @winexists(#Child1)
# Select and close the correct child dialog
%i = @DialogID(Child1)
dialog select,%i
dialog close
# Delete Dialog from DialogID List - must come after selecting and closing dialog
DialogID Delete,Child1
# Clear extra close event
%x = @event()
end
goto evloop
:child2_close
:child2_closebutton
if @winexists(#Child2)
# Select and close the correct child dialog
%i = @DialogID(Child2)
dialog select,%i
dialog close
# Delete Dialog from DialogID List - must come after selecting and closing dialog
DialogID Delete,Child2
# Clear extra close event
%x = @event()
end
goto evloop
:child3_close
:child3_closebutton
if @winexists(#Child3)
# Select and close the correct child dialog
%i = @DialogID(Child3)
dialog select,%i
dialog close
# Delete Dialog from DialogID List - must come after selecting and closing dialog
DialogID Delete,Child3
# Clear extra close event
%x = @event()
end
goto evloop
# Info buttons - only needed for demo
:child1_IDbutton
title child1_IDbutton
info Child 1 ID is @DialogID(Child1) ,
goto evloop
:child2_IDbutton
title child2_IDbutton
info Child 2 ID is @DialogID(Child2) ,
goto evloop
:child3_IDbutton
title child3_IDbutton
info Child 3 ID is @DialogID(Child3) ,
goto evloop
# GOSUB - only needed for demo
:StatusSet
if @winexists(#Main)
%i = @DialogID(Main)
dialog select,%i
dialog set,StatusMain,@tab()Dialog %i
end
if @winexists(#Child1)
%i = @DialogID(Child1)
dialog select,%i
dialog set,StatusChild1,@tab()Dialog %i
end
if @winexists(#Child2)
%i = @DialogID(Child2)
dialog select,%i
dialog set,StatusChild2,@tab()Dialog %i
end
if @winexists(#Child3)
%i = @DialogID(Child3)
dialog select,%i
dialog set,StatusChild3,@tab()Dialog %i
end
exit
# DialogID Function and Command
:DialogID
if @equal(%1,Add)
list add,%%DialogIDList,%2
elsif @equal(%1,Delete)
list seek,%%DialogIDList,0
%R = @match(%%DialogIDList,%2)
list delete,%%DialogIDList
elsif @numeric(%1)
%R = @item(%%DialogIDList,%1)
else
list seek,%%DialogIDList,0
%R = @match(%%DialogIDList,%1)
%R = @index(%%DialogIDList)
end
exit %R
|
_________________ cheers
Dave |
|