home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QBNWS202.ZIP / RODENT.ZIP / RODENT.BAS < prev    next >
Encoding:
BASIC Source File  |  1991-04-15  |  3.9 KB  |  138 lines

  1. ' ===========================================================================
  2. '   MODULE: RODENT.BAS
  3. '
  4. '   Demonstartion of the Microsoft (tm) Compatible Mouse Driver for
  5. '   QuickBASIC 4.5
  6. '
  7. '           Copyright (c) 1991
  8. '           Daniel R. Berry (Traveller Software)
  9. '           All Rights Reserved
  10. '
  11. '   This code is released to the Public Domain for distribution with the
  12. '   QBNews.
  13. '
  14. '   Daniel R. Berry
  15. '   3110-C S. Gen McMullen
  16. '   San Antonio, TX  78226
  17. '
  18. '   To start:  QB RODENT /L QB
  19. '
  20. ' ===========================================================================
  21. '
  22. '   $INCLUDE: 'MOUSE.BI'
  23. '
  24. DECLARE SUB CPrint (Row%, Col%, Fore%, Back%, Prompt$)
  25. DECLARE SUB ShortDelay (SDelay%)
  26. DECLARE SUB MouseCheck (Flag%)
  27. DECLARE SUB MouseInformation (MouseVer$, MouseType%, MouseType$)
  28. DECLARE SUB MouseLimitsRC (Row1%, Col1%, Row2%, Col2%)
  29. DECLARE SUB MouseMotion (Horz%, Vert%)
  30. DECLARE SUB MouseOn ()
  31. DECLARE SUB MouseStatusRC (Left%, Right%, Row%, Col%)
  32. DEFINT A-Z
  33. '
  34. '   Determine if mouse is available
  35. '
  36.     Flag = -1: CALL MouseCheck(Flag)
  37.     IF Flag <> 1 THEN
  38.         COLOR 15, 1: CLS
  39.         CALL CPrint(5, 0, 30, 1, "Unable to continue - Mouse Driver Software not found!")
  40.         CALL CPrint(7, 0, 12, 1, "Program....Halted")
  41.         COLOR 15, 1
  42.         BEEP: END
  43.     END IF
  44. '
  45. '   Get some information about the mouse
  46. '
  47.     CALL MouseInformation(MouseVer$, MouseType%, MouseType$)
  48. '
  49. '    Setup the Screen - Draw Box
  50. '
  51.     COLOR 15, 1: CLS
  52.     PRINT CHR$(201); STRING$(78, 205); CHR$(187);
  53.     FOR X = 2 TO 14
  54.         PRINT CHR$(186); SPACE$(78); CHR$(186);
  55.     NEXT
  56.     PRINT CHR$(200); STRING$(78, 205); CHR$(188);
  57.     '
  58.     '   Fill it in
  59.     '
  60.         FOR Y = 2 TO 14
  61.             CALL CPrint(Y, 2, 15, 1, STRING$(78, CHR$(249)))
  62.         NEXT
  63. '
  64. '   Place the information items on the screen
  65. '
  66.     CALL CPrint(17, 0, 0, 1, "Mouse Driver Version: " + MouseVer$ + SPACE$(5) + "Mouse Type: " + MouseType$)
  67.  
  68.     CALL CPrint(16, 23, 0, 1, "Mouse Limits are set within the BOX")
  69.     CALL CPrint(25, 13, 0, 1, "Mouse Interface Demonstration Program By: Daniel R. Berry")
  70.    
  71.     CALL CPrint(19, 4, 15, 1, "Mouse Row:")
  72.     CALL CPrint(20, 4, 15, 1, "Mouse Col:")
  73.   
  74.     CALL CPrint(19, 24, 15, 1, "Horizontal Motion:")
  75.     CALL CPrint(20, 24, 15, 1, "Vertical Motion:")
  76.    
  77.     CALL CPrint(19, 56, 15, 1, "Left Button:")
  78.     CALL CPrint(20, 56, 15, 1, "Right Button:")
  79. '
  80. '   Place the information box on the screen
  81. '
  82.     LOCATE 22, 1
  83.     PRINT CHR$(201); STRING$(78, 205); CHR$(187);
  84.         PRINT CHR$(186); SPACE$(78); CHR$(186);
  85.     PRINT CHR$(200); STRING$(78, 205); CHR$(188);
  86.    
  87.     LOCATE 23, 24: PRINT "Depress both Mouse buttons to EXIT"
  88.     '
  89.     '   Set the mouse limits to stay in Box
  90.     '
  91.         CALL MouseLimitsRC(2, 2, 14, 79)
  92.         CALL MouseOn ' Show us the Mouse
  93. '
  94. '   This is the main loop for the demonstration program.  Here we will
  95. '   determine various information about the mouse and tell the user what
  96. '   is going on.
  97. '
  98. DEMOLoop:
  99.     CALL MouseStatusRC(Left, Right, Row, Col)
  100.     CALL MouseMotion(Horz, Vert)
  101.  
  102.     Horz$ = "Still"
  103.     IF Horz <> 0 THEN
  104.         IF Horz < 0 THEN Horz$ = "Left " ELSE Horz$ = "Right"
  105.     END IF
  106.     Vert$ = "Still"
  107.     IF Vert <> 0 THEN
  108.         IF Vert < 0 THEN Vert$ = "Up   " ELSE Vert$ = "Down "
  109.     END IF
  110.     MLeft$ = "Normal   ": IF Left < 0 THEN MLeft$ = "Depressed"
  111.     MRight$ = "Normal   ": IF Right < 0 THEN MRight$ = "Depressed"
  112.  
  113.     CALL CPrint(19, 15, 15, 1, RIGHT$("0" + LTRIM$(STR$(Row)), 2))
  114.     CALL CPrint(20, 15, 15, 1, RIGHT$("0" + LTRIM$(STR$(Col)), 2))
  115.    
  116.     CALL CPrint(19, 43, 15, 1, Horz$)
  117.     CALL CPrint(20, 43, 15, 1, Vert$)
  118.              
  119.     CALL CPrint(19, 70, 15, 1, MLeft$)
  120.     CALL CPrint(20, 70, 15, 1, MRight$)
  121. '
  122. '   If both buttons depressed then exit program
  123. '
  124.     IF Left < 0 AND Right < 0 THEN
  125.             CALL MouseCheck(-2) ' Disable Mouse
  126.             CALL CPrint(23, 0, 15, 1, SPACE$(60))
  127.             CALL CPrint(23, 0, 12, 1, "Program....Halted")
  128.             COLOR 15, 1
  129.             CALL ShortDelay(100) ' Pause
  130.             END
  131.         ELSE
  132.     '
  133.     '   The delay is to give the user time to see the mouse status
  134.     '
  135.             CALL ShortDelay(10): GOTO DEMOLoop
  136.     END IF
  137.  
  138.