// This example shows the use of Windows API calls.  Use this to
// learn how to incorporate the API into the programs you write.

// Each type of interface control(i.e.:EDIT BOX, PUSH BUTTON,
// SCROLL BAR, etc.) is given two procedures.  For example, the
// routines for creating an EDIT BOX are in a PROCEDURE called
// PROCEDURE make_EditTextBox, and the routines for handling it
// are in the PROCEDURE called PROCEDURE hndl_EditTextBox.

// Run the program to get an idea of what it is doing, then look
// at the code to see how it is doing it.  The best way to learn
// a new language is to look at someone else's code, so look at
// and modify the commands in this example and you should be well
// on the way to being an expert API/GFA-BASIC programmer.

// PRESS ALT-Q WHILE CURSOR IS ON A FOLDED(hidden) PROCEDURE
// TO UNFOLD IT(show the code).

main
> PROCEDURE main
  set_up                          // RUN THE SET-UP PROCEDURE
  x&=_X,y&=_Y                     // GET THE X & Y RESOLUTIONS
  OPENW #1,x&/2-300,y&/2-200,600,400,496
  //                              // OPEN THE MAIN WINDOW
  main_param%= WS_VISIBLE | WS_CHILDWINDOW | DEFPUSHBUTTON
  //                              // DEFINE THE PARAMETERS FOR A PUSHBUTTON
  id_mainbutton&=CreateWindow("BUTTON","NEXT",main_param%,_X/2-30,_Y-50,60,30,WIN(1),0,_INSTANCE,0)
  //                              // PLACE A PUSHBUTTON AT THE BOTTOM OF THE
  //                              // MAIN WINDOW AND CALL THE BUTTON "NEXT"

  //   THE FOLLLOWING CALL VARIOUS PROCEDURES.  CLS CLEARS THE TOP WINDOW.
  dud
  make_EditTextBox
  hndl_EditTextBox
  CLS
  make_ListBox
  hndl_ListBox
  CLS
  make_ComboBox
  hndl_ComboBox
  CLS
  make_PushButton
  hndl_PushButton
  CLS
  make_RadioButton
  hndl_RadioButton
  CLS
  make_CheckBox
  hndl_CheckBox
  CLS
  make_3StateBox
  hndl_3StateBox
  CLS
  SSORT text$()                   // SORT THE STRING ARRAY ALPHABETICALLY
  make_StaticV
  make_VSlider
  hndl_VSlider
  CLS
  make_StaticH
  make_HSlider
  hndl_HSlider
  CLS
  @quit_it
RETURN
> PROCEDURE set_up
  DIM text$(20)                   // MAKE A STRING ARRAY WITH 20 ELEMENTS
  //                              // tHE FOLLOWING FILLS THE ARRAY
  text$(0)="D: Fourth item"
  text$(1)="F: Sixth item"
  text$(2)="A: First item"
  text$(3)="K: Eleventh item"
  text$(4)="N: Fourteenth item"
  text$(5)="E: Fifth item"
  text$(6)="J: Tenth item"
  text$(7)="B: Second item"
  text$(8)="O: Fifteenth item"
  text$(9)="G: Seventh item"
  text$(10)="L: Twelfth item"
  text$(11)="R: eighteenth item"
  text$(12)="I: Ninth item"
  text$(13)="T: Twentieth item"
  text$(14)="M: Thirteenth item"
  text$(15)="C: Third item"
  text$(16)="Q: Seventeenth item"
  text$(17)="S: Ninteenth item"
  text$(18)="H: Eighth item"
  text$(19)="P: Sixteenth item"

RETURN
> PROCEDURE make_EditTextBox
  edit_text$="This is an Edit Text Box.  Please type in some text and press the button."
  //                              // TEXT FOR EDIT BOX
  edit_param%=WS_VISIBLE | WS_CHILDWINDOW | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_LEFT
  //                              // STYLE FOR EDIT BOX
  id_edit&=CreateWindow("EDIT",edit_text$,edit_param%,10,10,_X-20,25,WIN(1),1,_INSTANCE,0)
  //                              // MAKE EDIT BOX
  ~SetFocus(id_edit&)             // MAKE THE EDIT BOX ACTIVE
RETURN
> PROCEDURE hndl_EditTextBox
  DO
    PEEKEVENT                     // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    //                            // MULTI-TASKING, ETC...)
    IF MENU(1)=4                  // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                   // REMOVE MAIN WINDOW
      EDIT                        // RETURN TO EDITOR
    ENDIF
    gf%=GetFocus()                // RETURN ADDRESS OF CURRENT ACTIVE OBJECT
  LOOP UNTIL gf%<>id_edit&        // QUIT LOOP IF ADDRESS IS NOT THE EDIT BOX
  ed_text$=""
  ed_text$=_WIN$(id_edit&)        // GET THE NEW TEXT FROM THE EDIT BOX
  ~DestroyWindow(id_edit&)        // REMOVE THE EDIT BOX
  WIN #1                          // ACTIVATE THE MAIN WINDOW
  PRINT AT(0,5);"Original text:"  // PRINT OUT THE ORIGINAL TEXT
  PRINT edit_text$
  PRINT
  PRINT "New text:"               // PRINT OUT THE NEW TEXT
  PRINT ed_text$
  ~SetFocus(id_dud&)              // MAKE THE DUD WINDOW ACTIVE.
  hold                            // RUN THE HOLD PROCEDURE
RETURN
> PROCEDURE make_ListBox
  LET list_text$=""
  //                              // NO TEXT FOR LIST BOX
  LET list_param%=WS_VISIBLE | WS_CHILDWINDOW | WS_BORDER | LBS_HASSTRINGS | LBS_MULTICOLUMN | LBS_MULTIPLESEL | LBS_SORT
  //                              // STYLE FOR LIST BOX
  id_list&=CreateWindow("LISTBOX",list_text$,list_param%,25,40,_X-50,80,WIN(1),2,_INSTANCE,0)
  //                              // MAKE LIST BOX

  ~SendMessage(id_list&,LB_SETCOLUMNWIDTH,130,0)
  //                              // MAKE EACH LIST BOX CELL BIG ENOUGH FOR
  //                              // THE LARGEST STRING
  FOR x&=0 TO 19
    ~SendMessage(id_list&,LB_ADDSTRING,0,text$(x&))
    //                            // FILL THE LIST BOX WITH THE ARRAY
    //                            // THE TEXT WILL IN ALPHABETICAL ORDER
    //                            // BECAUSE OF THE LBS_SORT PARAMETER
    //                            // ABOVE
    //                            //
  NEXT x&
  ~SetFocus(id_list&)             // MAKE THE LIST BOX ACTIVE

RETURN
> PROCEDURE hndl_ListBox
  PRINT AT(0,10);"Select some items"
  DO
    PEEKEVENT                     // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                  // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                   // REMOVE MAIN WINDOW
      EDIT                        // RETURN TO EDITOR
    ENDIF
    gf%=GetFocus()                // RETURN ADDRESS OF CURRENT ACTIVE OBJECT
  LOOP UNTIL gf%<>id_list&        // END LOOP IF LIST BOX IS NOT ACTIVE

  PRINT AT(0,10);"You picked items: ";
  FOR a%=0 TO 19
    picked%=SendMessage(id_list&,LB_GETSEL,a%,0)
    //                            // GET SELECT STATUS OF ITEM #a%
    IF picked%=1                  // IF STATUS = SELECTED
      PRINT a%+1;", ";            // PRINT THE NUMBER OF THE ITEM
    ENDIF
  NEXT a%

  ~DestroyWindow(id_list&)        // REMOVE THE LIST BOX
  ~SetFocus(id_dud&)              // MAKE THE DUD BUTTON ACTIVE
  hold
RETURN

> PROCEDURE make_ComboBox
  combo_text$=""
  //                            // NO TEXT FOR COMBO BOX
  combo_param%=WS_VISIBLE | WS_CHILDWINDOW | WS_BORDER | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT
  //                            // STYLE FOR COMBO BOX
  id_combo&=CreateWindow("COMBOBOX",combo_text$,combo_param%,235,140,155,140,WIN(1),3,_INSTANCE,0)
  //                            // MAKE COMBO BOX

  FOR x&=0 TO 19
    ~SendMessage(id_combo&,CB_ADDSTRING,0,text$(x&))
    //                          // FILL COMBO BOX WITH STRING ARRAY
    //                          // TEXT WILL BE IN ALPHABETICAL ORDER
    //                          // BECAUSE OF THE CBS_SORT PARAMETER
    //                          // ABOVE
  NEXT x&
  ~SetFocus(id_combo&)          // MAKE THE COMBO BOX ACTIVE

RETURN
> PROCEDURE hndl_ComboBox
  PRINT AT(0,10);"Select an item."
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
    gf%=GetFocus()              // RETURN ADDRESS OF CURRENT ACTIVE OBJECT
  LOOP UNTIL gf%<>id_combo&     // END LOOP IF COMBO BOX IS NOT ACTIVE

  picked&=SendMessage(id_combo&,CB_GETCURSEL,0,0)
  //                            // WHAT IS THE INDEX OF THE SELECTED ITEM
  ~SendMessage(id_combo&,CB_GETLBTEXT,picked&,V:temp$)
  //                            // WHAT IS THE TEXT OF THE SELECTED ITEM
  picked$=CHAR{V:temp$}
  IF picked&<0                  // IF NO ITEM WAS PICKED
    PRINT "You did not pick an item"
  ELSE
    PRINT AT(0,10);"You picked item: #";picked&+1
    PRINT "The text in that item was ";CHR$(34);picked$;CHR$(34)
  ENDIF
  ~DestroyWindow(id_combo&)     // REMOVE THE COMBO BOX
  ~SetFocus(id_dud&)            // MAKE THE DUD BUTTON ACTIVE
  hold

RETURN
> PROCEDURE make_PushButton
  pbutt_text$="PushButton"
  //                            // PUSH BUTTON IS CALLED PushButton
  pbutt_param%=WS_VISIBLE | WS_CHILDWINDOW | BS_PUSHBUTTON
  //                            // STYLE FOR PUSH BUTTON
  id_pbutt&=CreateWindow("BUTTON",pbutt_text$,pbutt_param%,425,140,125,40,WIN(1),4,_INSTANCE,0)
  //                            // MAKE PUSH BUTTON

RETURN
> PROCEDURE hndl_PushButton
  PRINT AT(0,10);"Push the Push Button as many time as you wish."
  a&=0
  b&=0
  pbutt_num&=0
  ~SetFocus(id_dud&)            // MAKE THE DUD BUTTON ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
    info&=SendMessage(id_pbutt&,BM_GETSTATE,0,0)
    //                          // WAS THE BUTTON PRESSED?
    IF info&>0
      'PRINT info&
      pbutt_num&++
      ~SetFocus(id_dud&)        // MAKE THE DUD BUTTON ACTIVE
    ENDIF
    info&=0
  LOOP UNTIL GetFocus()=id_mainbutton&
  //                            // QUIT LOOP IF MAIN BUTTON WAS PRESSED
  IF pbutt_num&<>1
    s$="s."
  ELSE
    s$="."
  ENDIF
  PRINT AT(0,10);"You pushed the Push Button ";pbutt_num&;" time";s$;"                                                            "
  ~DestroyWindow(id_pbutt&)     // REMOVE THE PUSH BUTTON
  hold
RETURN
> PROCEDURE make_RadioButton
  rbutt_text$="RadioButton"     // RADIO BUTTON IS CALLED RadioButton
  rbutt_param%=WS_VISIBLE | WS_CHILDWINDOW | BS_AUTORADIOBUTTON
  //                            // STYLE FOR RADIO BUTTONS

  id_rbutt1&=CreateWindow("BUTTON",rbutt_text$+"1",rbutt_param%,100,_Y-80,110,30,WIN(1),5,_INSTANCE,0)
  id_rbutt2&=CreateWindow("BUTTON",rbutt_text$+"2",rbutt_param%,245,_Y-80,110,30,WIN(1),6,_INSTANCE,0)
  id_rbutt3&=CreateWindow("BUTTON",rbutt_text$+"3",rbutt_param%,390,_Y-80,110,30,WIN(1),7,_INSTANCE,0)
  //                            // MAKE 3 RADIO BUTTONS

RETURN
> PROCEDURE hndl_RadioButton
  PRINT AT(0,10);"Select a Radio Button."
  ~SetFocus(id_rbutt1&)         // MAKE THE RADIO BUTTON ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
  LOOP UNTIL GetFocus()=id_mainbutton&
  //                            // QUIT LOOP IF MAIN BUTTON IS PRESSED
  info1&=SendMessage(id_rbutt1&,BM_GETSTATE,0,0)
  //                            // IS BUTTON ACTIVE?
  IF info1&=0
    info2&=SendMessage(id_rbutt2&,BM_GETSTATE,0,0)
    //                          // IS BUTTON ACTIVE?
    IF info2&=0
      info3&=SendMessage(id_rbutt3&,BM_GETSTATE,0,0)
      //                        // IS BUTTON ACTIVE?
      IF info3&=0
        rbutt_num&=4
      ELSE
        rbutt_num&=3
      ENDIF
    ELSE
      rbutt_num&=2
    ENDIF
  ELSE
    rbutt_num&=1
  ENDIF
  IF rbutt_num&=4
    PRINT AT(0,10);"Not Radio Button was selected                                                                            "
  ELSE
    PRINT AT(0,10);"Radio Button #";rbutt_num&;" was selected.                                                "                                                           ;""
  ENDIF
  ~DestroyWindow(id_rbutt1&)    // REMOVE THE RADIO BUTTON
  ~DestroyWindow(id_rbutt2&)    // REMOVE THE RADIO BUTTON
  ~DestroyWindow(id_rbutt3&)    // REMOVE THE RADIO BUTTON

  hold
RETURN
> PROCEDURE make_CheckBox
  cbox_text$="CheckBox"         // CHECK BOX IS CALLED CheckBox
  cbox_param%=WS_VISIBLE | WS_CHILDWINDOW | BS_AUTOCHECKBOX
  //                            // STYLE FOR CHECK BOX
  id_cbox&=CreateWindow("BUTTON",cbox_text$,cbox_param%,425,190,110,30,WIN(1),8,_INSTANCE,0)
  //                            // MAKE CHECK BOX

RETURN
> PROCEDURE hndl_CheckBox
  PRINT AT(0,10);"Push the Check Box a few times."
  ~SetFocus(id_cbox&)           // MAKE THE CHECK BOX ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
  LOOP UNTIL GetFocus()=id_mainbutton&
  //                            // QUIT LOOP IF MAIN BUTTON IS ACTIVE
  info&=SendMessage(id_cbox&,BM_GETCHECK,0,0)
  //                            // WAS CHECK BOX CHECKED?
  IF info&=0
    rbutt_set$=" not"
  ELSE
    rbutt_set$=""
  ENDIF
  PRINT AT(0,10);"The Check Box was";rbutt_set$;" set.                              "                                                           ;""
  ~DestroyWindow(id_cbox&)      // REMOVE THE CHECK BOX
  hold
RETURN

> PROCEDURE make_3StateBox
  s3box_text$="3SateBox"        // 3 STATE BOX IS CALLED 3StateBox
  s3box_param%=WS_VISIBLE | WS_CHILDWINDOW | BS_AUTO3STATE
  //                            // STYLE FOR 3 STATE BOX
  id_s3box&=CreateWindow("BUTTON",s3box_text$,s3box_param%,425,230,110,30,WIN(1),9,_INSTANCE,0)
  //                            // MAKE A 3 STATE BOX

RETURN
> PROCEDURE hndl_3StateBox
  PRINT AT(0,10);"Push the 3 State Box a few times."
  ~SetFocus(id_s3box&)          // MAKE THE 3 STATE BOX ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
  LOOP UNTIL GetFocus()=id_mainbutton&
  //                            // QUIT LOOP IF MAINBUTTON WAS PRESSED
  info&=SendMessage(id_s3box&,BM_GETCHECK,0,0)
  //                            // IS CHECK BOX BLANK, CHECKED, OR GRAYED?
  IF info&=1
    s3box_set$=" checked."
  ELSE IF info&=2
    s3box_set$=" grayed."
  ELSE
    s3box_set$=" not selected."
  ENDIF
  PRINT AT(0,10);"The 3 State Box was";s3box_set$;"                                                           "
  'PRINT info&
  ~DestroyWindow(id_s3box&)     // REMOVE THE 3 STATE BOX
  hold
RETURN

> PROCEDURE make_StaticV
  statv_text$=""                // NO TEXT IN STATIC WINDOW
  statv_param%=SS_LEFT | WS_BORDER | WS_VISIBLE | WS_CHILDWINDOW
  //                            // STYLE FOR STATIC WINDOW
  id_staticv&=CreateWindow("STATIC",statv_text$,statv_param%,25,140,155,145,WIN(1),10,_INSTANCE,0)
  hndl_StaticV(1)
RETURN
> PROCEDURE hndl_StaticV(pass&)
  vert_text$=""
  FOR x&=0 TO 8
    vert_text$=vert_text$+text$(pass&+x&)+CHR$(13)
    //                          // PUT TEXT ARRAY INTO ONE STRING
  NEXT x&
  ~SendMessage(id_staticv&,WM_SETTEXT,0,V:vert_text$)
  //                            // COPY STRING TO STATIC WINDOW
RETURN
> PROCEDURE make_VSlider
  vslid_text$=""                // NO TEXT IN VERTICAL SLIDER BAR
  vslid_param%=WS_VISIBLE | WS_CHILDWINDOW | SBS_VERT
  //                            // STYLE FOR VERTICAL SLIDER BAR
  id_vslid&=CreateWindow("SCROLLBAR",vslid_text$,vslid_param%,179,140,18,145,WIN(1),11,_INSTANCE,0)
  //                            // MAKE VERTICAL SLIDER BAR
RETURN
> PROCEDURE hndl_VSlider
  ~SetFocus(id_vslid&)          // MAKE THE VERTICAL SCROLL BAR ACTIVE
  ctl&=SB_CTL
  ~SetScrollRange(id_vslid&,ctl&,1,12,0)
  //                            // SET SCROLL BAR WITH 12 POSITIONS
  ~SetScrollPos(id_vslid&,ctl&,0,1)
  //                            // SET SCROLL BAR TO POSITION 1
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
    m1&=MENU(1)                 // GET WINDOWS MESSAGES
    IF m1&>6 AND m1&<17         // WAS IT A SCROLL BAR MESSAGE?
      m7&=MENU(7)               // WAS IT A LINE UP?
      IF m1&=7
        send&--
        PRINT AT(30,10);"Line up                                         "
        IF send&<1 THEN send&=1
      ELSE IF m1&=8             // WAS IT A LINE DOWN?
        send&++
        PRINT AT(30,10);"Line down                                       "
        IF send&>12 THEN send&=12
      ELSE IF m1&=11            // WAS IT A PAGE UP?
        send&=send&-8
        PRINT AT(30,10);"Page up                                         "
        IF send&<1 THEN send&=1
      ELSE IF m1&=12            // WAS IT A PAGE DOWN?
        send&=send&+8
        PRINT AT(30,10);"Page down                                       "
        IF send&>12 THEN send&=12
      ELSE IF m1&=15            // WAS IT A "THUMBED" SCROLL
        //                      // (IE: USER PHYSICALLY MOVE THE SCROLL BOX)
        send&=m7&
        PRINT AT(30,10);"Slider moved to position ";send&;".             "
      ENDIF
      'PRINT send&
      ~SetScrollPos(id_vslid&,ctl&,send&,1)
      //                        // SET SCROLL BAR TO POSITION send&
      hndl_StaticV(send&)       // RUN PROCEDURE hndl_StaticV AND PASS
      //                        // THE PARAMETER send&

    ENDIF
  LOOP UNTIL GetFocus()=id_mainbutton&
  //                            // QUIT LOOP IF THE MAIN BUTTON WAS PRESSED
  ~DestroyWindow(id_vslid&)     // REMOVE THE VERTICAL SLIDER BAR
  ~DestroyWindow(id_staticv&)   // REMOVE THE STATIC WINDOW

RETURN
> PROCEDURE make_StaticH
  stath_text$=""                // NO TEXT IN STATIC WINDOW
  stath_param%=SS_LEFT | WS_BORDER | WS_VISIBLE | WS_CHILDWINDOW
  //                            // STYLE FOR STATIC WINDOW
  id_statich&=CreateWindow("STATIC",stath_text$,stath_param%,235,180,155,80,WIN(1),12,_INSTANCE,0)
  //                            // MAKE STATIC WINDOW
  hndl_StaticH(1)
RETURN
> PROCEDURE hndl_StaticH(pass&)
  horz_text$="  "
  FOR x&=0 TO 4
    horz_text$=horz_text$+text$(pass&+x&)+CHR$(13)+"   "
    //                          // FILL STRING WITH TEXT ARRAY
  NEXT x&
  ~SendMessage(id_statich&,WM_SETTEXT,0,V:horz_text$)
  //                            // SEND STRING TO STATIC WINDOW
RETURN
> PROCEDURE make_HSlider
  hslid_text$=""                // NO TEXT IN HORIZONTAL SCROLL BAR
  hslid_param%=WS_VISIBLE | WS_CHILDWINDOW | SBS_HORZ
  //                            // STYLE FOR HORIZONTAL SCROLL BAR
  id_hslid&=CreateWindow("SCROLLBAR",hslid_text$,hslid_param%,235,259,155,20,WIN(1),13,_INSTANCE,0)
  //                            // MAKE HORIZONTAL SCROLL BAR
RETURN
> PROCEDURE hndl_HSlider
  ~SetFocus(id_hslid&)          // MAKE THE HORIZONTAL SCROLL BAR ACTIVE
  ctl&=SB_CTL
  ~SetScrollRange(id_hslid&,ctl&,1,16,0)
  //                            // SET SCROLL BAR WITH 16 POSITIONS
  ~SetScrollPos(id_hslid&,ctl&,0,1)
  //                            // SET SCROLL BAR TO POSITION 1
  send&=1
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
    m1&=MENU(1)                 // GET WINDOWS MESSAGE
    IF m1&>6 AND m1&<17         // WAS IT A SCROLL BAR MESSAGE?
      m7&=MENU(7)               // WAS IT LINE LEFT?
      IF m1&=9
        send&--
        PRINT AT(30,10);"Line left                                       "
        IF send&<1 THEN send&=1
      ELSE IF m1&=10            // WAS IT LINE RIGHT?
        send&++
        PRINT AT(30,10);"Line right                                      "
        IF send&>16 THEN send&=16
      ELSE IF m1&=13            // WAS IT PAGE LEFT?
        send&=send&-5
        PRINT AT(30,10);"Page left                                       "
        IF send&<1 THEN send&=1
      ELSE IF m1&=14            // WAS IT PAGE RIGHT?
        send&=send&+5
        PRINT AT(30,10);"Page right                                      "
        IF send&>16 THEN send&=16
      ELSE IF m1&=16            // WAS IT A "THUMBED" SCROLL BOX
        //                      // (IE: USER PHYSICALLY MOVE THE SCROLL BOX)
        send&=m7&
        PRINT AT(30,10);"Slider moved to position ";send&;".             "
      ENDIF
      'PRINT send&
      ~SetScrollPos(id_hslid&,ctl&,send&,1)
      //                        // SET SCROLL BAR TO POSITITION
      hndl_StaticH(send&)
    ENDIF
  LOOP UNTIL MENU(1)=4 OR GetFocus()=id_mainbutton&
  ~DestroyWindow(id_hslid&)     // REMOVE THE HORIZONTAL SLIDER BAR
  ~DestroyWindow(id_statich&)   // REMOVE THE STATIC WINDOW
RETURN
> PROCEDURE quit_it
  quit$="QUIT"
  ~SendMessage(id_mainbutton&,WM_SETTEXT,0,quit$)
  //                            // CHANGE MAIN BUTTON FROM NEXT TO QUIT
  PRINT AT(0,10); "Press button to quit."
  ~SetFocus(id_dud&)            // MAKE THE DUD BUTTON ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    gf%=GetFocus()              // RETURN ADDRESS OF CURRENT ACTIVE OBJECT
  LOOP UNTIL MENU(1)=4 OR gf%<>id_dud&
  //                            // QUIT LOOP IF MAIN BUTTON IS PRESSED OR
  //                            // QUIT APPLICTION OR ALT-F4 IS HIT

  CLOSEW #1                     // REMOVE MAIN WINDOW
RETURN
> PROCEDURE hold
  ~SetFocus(id_dud&)            // MAKE THE DUD BUTTON ACTIVE
  DO
    PEEKEVENT                   // HANDLE WINDOWS EVENTS(IE: MESSAGES,
    IF MENU(1)=4                // IF THE QUIT OPTION(OR ALT-F4) WAS HIT
      CLOSEW #1                 // REMOVE MAIN WINDOW
      EDIT                      // RETURN TO EDITOR
    ENDIF
    gf%=GetFocus()              // RETURN ADDRESS OF CURRENT ACTIVE OBJECT
  LOOP UNTIL gf%<>id_dud&
RETURN
PROCEDURE dud
  id_dud&=CreateWindow("BUTTON","",main_param%,0,0,0,0,WIN(1),30,_INSTANCE,0)
  //                            // MAKE AN INVISIBLE "DUD" BUTTON
  ~SetFocus(id_dud&)            // MAKE THE DUD BUTTON ACTIVE
RETURN
