forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Multiple Child Windows...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Nov 19, 2002 10:43 am    Post subject: Multiple Child Windows... Reply with quote

Creates multiple windows and matches events to the
appropriate one.

This example allows the user to open an unlimited
number of cascading resizable child windows with
edit boxes. Click "File" then select "New Window"
to open a child window.
__________________________________________________________________________________________________________________________
Code:

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
%%main = "Multiple Child Windows"
DIALOG CREATE,%%main,20,20,500,300,RESIZABLE
  DIALOG ADD,MENU,&File,&New Window,-,E&xit|Alt+X
  DIALOG ADD,EDIT,MainEdit,0,0,500,300,,,MULTI,SCROLL
DIALOG SHOW

rem -- For child dialog numbers --
LIST CREATE, 1
LIST ADD, 1, ""
%%num = 0

:EVLOOP
  WAIT EVENT
  rem -- %e is event, %d is dialog number that issued it (0,1,2,etc.) --
  PARSE "%e;%d", @event(d)
  DIALOG SELECT, %d
  goto %e

:RESIZE
  LIST SEEK, 1, 0
  if @match(1, @winactive())
     %d = @index(1)
     PARSE "%%window;%%edit", @item(1)
     DIALOG SETPOS, %%edit, 0, 0, @diff(@winpos(%%window, W), 8), @diff(@winpos(%%window, H), 26)
  else
     DIALOG SETPOS, MainEdit, 0, 0, @diff(@winpos(%%main, W), 8), @diff(@winpos(%%main, H), 46)
  end
  goto EVLOOP

:New WindowMENU
  %%num = @succ(%%num)
  %%top = @sum(@winpos(%%main, T), @prod(%%num, 20), 26)
  %%left = @sum(@winpos(%%main, L), @prod(%%num, 20))
  LIST ADD, 1,"Child Window "%%num|"Edit"%%num
  DIALOG CREATE,"Child Window "%%num,%%top,%%left,300,200,ONTOP,RESIZABLE
    DIALOG ADD,EDIT,"Edit"%%num,0,0,300,200,,,MULTI,SCROLL
  DIALOG SHOW
  goto EVLOOP

:ExitMENU
:CLOSE
  if @greater(%d, 0)
     DIALOG CLOSE
     LIST SEEK, 1, %d
     LIST DELETE, 1
     %e = @event()
     goto EVLOOP
  end
  EXIT

EDIT - Changed EVLOOP to select appropriate dialog (thanks
to cnodnarb for this).

Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361


Last edited by Mac on Wed Dec 11, 2002 1:35 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Wed Dec 11, 2002 1:24 am    Post subject: Reply with quote

To avoid having to select dialog during an event occurance replace evloop with below. This will avoid having the wrond dialog selected when referencing controls.

Code:

:evloop
wait event
parse "%e;%d",@event(d)
dialog select,%d
goto %e


NodNarb
Back to top
View user's profile Send private message AIM Address
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Dec 11, 2002 1:37 am    Post subject: Reply with quote

Good idea, that saves a lot of code. Wink

I changed the code example above.

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Wed Dec 11, 2002 12:19 pm    Post subject: Reply with quote

Runs great Mac - nice job!

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Dec 11, 2002 10:50 pm    Post subject: Reply with quote

Thanks Serge. Smile

BTW guys, selecting the dialog from the EVLOOP requires
special handling of TIMER events. TIMER events will parse
the last dialog selected into %d, and if it's closed ya get an
error.

So if ya don't use separate EVLOOPs for child windows,
use something like this to catch TIMER events: Wink
Code:

:TIMER
  rem -- Do nothing, this is just a test --
:EVLOOP
  WAIT EVENT, 1
  rem -- %e is event, %d is dialog number that issued it (0,1,2,etc.) --
  PARSE "%e;%d", @event(d)
  if @equal(%e, "TIMER")
     goto TIMER
  end
  DIALOG SELECT, %d
  goto %e

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Thu Dec 12, 2002 2:13 pm    Post subject: Reply with quote

How many ways are there to tackle an issue? How many programmers are there to discuss it? Same answer Wink

Code:

:evloop
wait 1
%%eventdialog = @event(d)
parse "%%event;%%dialog",%%eventdialog
if %%event
dialog select,%%dialog
goto %%event
else
rem commands and functions to occur while idle go here
end
rem or here
goto evloop
Back to top
View user's profile Send private message AIM Address
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Dec 12, 2002 9:44 pm    Post subject: Reply with quote

Well, all things being equal, I prefer less code
and fewer vars. The TIMER event is hard to beat. Wink

Your example can wait up to a full second before
processing an event (or longer if the idle stuff
needs more WAIT time).

If ya wanna use a loop, I'd go with REPEAT/UNTIL,
a shorter WAIT, and an incremented VAR for timing
idle events. Ya can either reset %%timer to zero at
the beginning of the loop, or once at the beginning
of the program to make it fulfill the count before
each timed event (even if ya do other stuff). Wink

Requires OPTION DECIMALSEP, "."
Code:

:EVLOOP
  %%timer = 0
  REPEAT
    WAIT ".5"
    %%timer  = @succ(%%timer )
    rem -- Do something approx every 5 seconds --
    if @equal(%%timer , 10)
       INFO Time to do something...@tab()
       %%timer  = 0
    end
    PARSE "%e;%d", @event(d)
  UNTIL %e
  DIALOG SELECT, %d
  goto %e

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Fri Dec 13, 2002 5:26 pm    Post subject: Reply with quote

*BANG*

Ooo, you got me Mac!

I didn't realize the additional advantage of using a TIMER label believe it or not!! When I needed the same ability I would break down my delay into multiple wait commands and check for events after each wait... Embarassed

NodNarb
Back to top
View user's profile Send private message AIM Address
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Dec 13, 2002 11:33 pm    Post subject: Reply with quote

LOL, musta been a lucky shot...

Laughing Laughing Laughing

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group