home *** CD-ROM | disk | FTP | other *** search
- '============================================================================
- ' GETYESNO.BAS - A sample program for QuickWindows Standard
- ' YES/NO Message Box Prompt
- '============================================================================
-
- REM $DYNAMIC
- DEFINT A-Z 'Make all variables integers by default.
- DIM SHARED w(4000) 'Dimension an integer array for our window.
- CALL QWINIT(4) 'Need to call this command before using any QW commands.
- CLS 'Clear the screen.
-
- Msg$ = "Sample message. Continue?"
- GOSUB GetYesNo
- LOCATE 21, 1
- IF (result = 0) AND (focus = 0) THEN
- PRINT "You've exited without making a selection."
- ELSE
- PRINT "You Selected: "; result
- END IF
- END
- '---------------------------------------------------------------------------
- ' GetYesNo - Display a message prompt in Msg$ and prompt user for Yes or No.
- ' Size of window is determined by length of Msg$.
- ' Window slot 1 is used.
- '
- GetYesNo:
- strlen = LEN(Msg$) 'Need length of string to print.
- wx1 = INT((80 - strlen) / 2) 'Center the window on the screen.
- wx2 = wx1 + strlen + 5 'Setup right border
- wy1 = 8 'Upper edge of window.
- wy2 = wy1 + 6 'Lower edge.
- wstyle = 1 'Window border style = Single line.
- wincolor = &H74 'Color = Red on White.
- title$ = "" 'No title in window.
- id = 1
- CALL WOPEN(wx1, wy1, wx2, wy2, wstyle, wincolor, title$, w(), id)
- CALL WCLS(id) 'Clear the window.
- CALL WLOCATE(id, 2, 0) '& Locate the cursor.
- CALL WPRINT(id, Msg$) '& Print our message.
- strlen2 = strlen / 2
- bstyle = 2
- bcolor = &H79
- CALL WBUTTONSET(id, 1, 0, bsytle, bcolor, 2, &H71, strlen2 - 9, 2, " No ")
- CALL WBUTTONSET(id, 2, 0, bstyle, bcolor, 2, &H71, strlen2 + 5, 2, " Yes ")
- focus = 1
- DO
- CALL WBUTTONGET(focus, 1, 2, result)
- IF (focus = 0) AND (result = 0) THEN EXIT DO 'Trap for Escape key.
- IF focus < 1 THEN
- focus = 2
- ELSEIF focus > 2 THEN
- focus = 1
- END IF
- LOOP WHILE result = 0
- CALL WCLOSE(id)
- RETURN
-
-