home *** CD-ROM | disk | FTP | other *** search
-
- Shareware delay box by Paul Jones for Atari Computing. Feel free to
- add this code to your own programs if you have the need. However, if
- you do add this code to your own program, you must announce this in
- the program's documentation.
-
- (c) Paul Jones and Renegade Publishing Ltd
-
- Shareware dialogs... what's tha' then?
- --------------------------------------
-
- You'd be forgiving for asking such a question, some people have never
- seen one before since or if they have, call it by another name, or
- nothing at all!
-
- A shareware delay bar is just what it sounds like. It's a bar in a
- dialog box which progresses to show how much time you've waited. Since
- it's shareware, indicating the author wishes you to pay money to
- "register" the software, he/she encourages you to do so by adding this.
- While the bar is display, you can't click on anything, in effect, your
- computer is frozen until the time is up... even on multitasking
- systems.
-
- The code in the file SHAREWAR.BAS is an example of such a bar, with
- source code and executable. The above is to be included in PDO (Print
- Documents Out) to encourage people to register.
-
- How does it work?
- -----------------
-
- It's quite simple really. First you design a normal form dialog, with
- two exceptions: 1) It doesn't have any exit buttons 2) It has a
- SLIDERBAR.
-
- A sliderbar is an object which can have it's size (width, height, x
- and y co-ordinates etc) edited within a program. These are usually
- boxes. There are actually two bars in a slide box, they are called the
- background and the foreground. The background one isn't edited at all,
- but used to find out the maximum size of the foreground sliderbar
- (this is the white bar in our example). The foreground one is the bar
- that moves (the blue one in our example).
-
- Once the RSC has been loaded into memory, we have to find the maximum
- width of the background bar since the foreground bar has it's width
- set to a small width (this is so we can actually click on the thing in
- the RSC editor, and also have access to the background bar too).
-
- Using the system clock we can increment this bar whenever we like (I
- use 100 milliseconds, which equals 0.1 second bursts). Instead of the
- usuall form handling routines, we don't ask for any button selections,
- so we come out of displaying the dialog instantly. We can then update
- the dialog whenever it changes.
-
- BASICally, it goes like this...
- -------------------------------
-
- Here is how the most important routines work in the program:
-
- SUB form_show (dial)
- STATIC junk,tree&,x,y,w,h,but,type_tree,treeno,tree&
-
- junk=FNrsrc_gaddr(0,dial,tree&)
- form_center tree&,x,y,w,h
- form_dial FMD_START,0,0,0,0,x,y,w,h
- junk=FNobjc_draw(tree&,0,10,x,y,w,h)
- END SUB
-
- This routine will first display the dialog box. It's a different model
- of our normal dialog box displayer, because we don't ask GEM to wait
- for a button to be pressed.
-
- SUB form_show_part (dial, object)
- STATIC junk,tree&,x,y,w,h,but,type_tree,treeno,tree&
- STATIC x2,y2,w2,h2
-
- junk=FNrsrc_gaddr(0,dial,tree&)
- form_center tree&,x,y,w,h
- SelectTree dial
-
- form_dial FMD_START,0,0,0,0,x,y,w,h
-
- junk=FNobjc_draw(tree&,object,0,x,y,w,h)
-
- END SUB
-
- This sub-routine can redraw parts of the dialog box for us. Notice the
- objc_draw () which actually displays the sliderbar on the screen.
-
- SUB GetSetObjects
- SHARED wwidth,swidth,spart
-
- SelectTree sharedial
- wwidth=FNgetob_width (whiteback)
-
- setob_width slidebar, 0
- swidth=0
-
- spart=wwidth/100
-
- END SUB
-
- This is quite an important routine. It first finds out the width of
- our background bar, then sets the foreground sliders width to 0. It
- then calculates how much to add to the sliderbar each time the below
- routine is called:
-
- SUB do_timer
- SHARED swidth,wwidth,spart
- SHARED finished
-
- swidth=swidth+spart
- IF swidth>wwidth THEN
- finished=-1
- ELSE
- setob_width slidebar,swidth
- form_show_part sharedial, slidebar
- END IF
-
- END SUB
-
- This part is called every 100 milliseconds. It adds on part of the
- slidebar to what already exists so gives the impression it's moving.
- If the new width is over the size of the orginall, then the program
- quits, otherwise the new size is implemented into the dialog and
- redrawn.
-
- DIM mess(16)
- StartProgram "SHAREWAR.RSC"
- GetSetObjects
-
- form_show (sharedial)
-
- DO
- e=FNevnt_multi(MU_TIMER,0,0,0,0,0,0,0,0,0,0,0,0,0,_
- VARPTR(mess(0)),100,0,0,0,0,k,0)
-
- IF e AND MU_TIMER THEN CALL do_timer
-
- IF finished=-1 THEN CALL StopProgram
-
- LOOP
-
- The main loop. First it loads up the dialogs into memory (notice this
- is different verion of StartProgram which we're used to). Then we set
- the objects size.
-
- The main evnt_multi contains another difference - instead of checking
- for GEM messages and keyboard clicks, we're just looking for
- MU_TIMERs. GEM will give us a signal whenever a certain amount of time
- in milliseconds passes (notice the 100 in the parameters list?).