home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / Basic / QWINDO.ZIP / BUTTON.BAS next >
Encoding:
BASIC Source File  |  1990-01-01  |  2.9 KB  |  70 lines

  1. '****************************************************************************
  2. ' BUTTON.BAS - Demo of how to use WBUTTONSET and WBUTTONGET .
  3. '****************************************************************************
  4. '
  5. ' WBUTTONSET has the following parameters
  6. '    WBUTTONSET(id,button#,kb,f-style,f-attr,nf-style,nf-attr,x,y,button$)
  7. '        id       = current opened window id
  8. '        button#  = a button number from 1 to 32
  9. '        kb       = kb value for direct button selection (enter 0 to inhibit)
  10. '        f-style  = box style for focused button (currently not used, fill with 1)
  11. '        f-attr   = attribute for focused button
  12. '        nf-style = box style for button [1-8]  (same as window styles)
  13. '        nf-attr  = attribute for button when it is not focused
  14. '        x,y      = starting position of button relative to start of window (0,0)
  15. '        button$  = string to place inside button (size of button depends on string len)
  16. '
  17. ' WBUTTONGET has the following parameters
  18. '    WBUTTONGET(focus,start,num_buttons,result)
  19. '        focus    = the button to focus when entering WBUTTONGET
  20. '        start    = starting button number to scan
  21. '        num_butt = number of buttons to scan
  22. '        result   = returns 0 if no action, otherwise a selected button
  23. '            If result=0 then you must loop to WBUTTONGET to keep active scan.
  24.  
  25. REM $DYNAMIC
  26. DEFINT A-Z              'Make all variables integers by default.
  27. DIM SHARED a%(2000)     'Dimension an integer array for our window.
  28. CALL QWINIT(4)          'Need to call this command before using any QW commands.
  29. CLS                     'Clear the screen.
  30.  
  31. '(1) First we have to open a window to use. ------------------------------
  32. id = 3                  'All references for a window through id #.
  33. wincolor = &H74         'Setup color for window.
  34.             'Used hex values so it's easier to see foreground
  35.             'and background. &H74 = Red on White.
  36. CALL WOPEN(20, 8, 58, 18, 2, &H74, "Window TITLE", a%(), id)
  37.  
  38. CALL WPRINT(id, "~ Use Arrow keys to switch focus,~ press Return to Select.")
  39.  
  40. '(2) Next we need to define the buttons inside the window. ----------------
  41. CALL WBUTTONSET(id, 1, 15104, 1, &H79, 2, &H71, 5, 5, "OK")
  42. CALL WBUTTONSET(id, 2, 15360, 1, &H79, 2, &H71, 13, 5, "Cancel")
  43. CALL WBUTTONSET(id, 3, 15616, 1, &H79, 2, &H71, 25, 5, "Save")
  44. LOCATE 21, 1
  45.  
  46. '(3) Now we can sit in a loop till user makes a selection.
  47. focus = 2: 'Input focus.
  48.        'Hightlight this button when entering WBUTTONGET.
  49.        'focus cannot be 0. Must be in range 1-3 in this example.
  50. DO
  51.     CALL WBUTTONGET(focus, 1, 3, result)
  52.     IF (result = 0) AND (focus = 0) THEN
  53.     PRINT "You've exited without selection."
  54.     END
  55.     END IF
  56.     IF focus < 1 THEN
  57.     focus = 3
  58.     ELSEIF focus > 3 THEN
  59.     focus = 1
  60.     END IF
  61.     'WBUTTONGET returns 0 on a continual basis if no action on a button.
  62. LOOP WHILE result = 0
  63. PRINT "You've selected button"; result;
  64. END
  65.  
  66.  
  67.  
  68.  
  69.  
  70.