QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _MOUSEWHEEL function returns a positive or negative INTEGER value indicating mouse scroll events since the last read of _MOUSEINPUT.

Syntax

scrollAmount% = _MOUSEWHEEL

Description

Example(s)

Reading the cumulative mouse wheel “clicks”.


 DO: _LIMIT 100
    DO WHILE _MOUSEINPUT
      Scroll = Scroll + _MOUSEWHEEL
      LOCATE 10, 20: PRINT Scroll
    LOOP
 LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit 

A simple text scrolling routine using the mouse wheel value to read a text array.


DIM Array$(100)
LINE INPUT "Enter a file name with 100 or more lines of text: ", file$
OPEN file$ FOR INPUT AS #1
DO UNTIL EOF(1)
  inputcount = inputcount + 1
  LINE INPUT #1, Array$(inputcount)
  IF inputcount = 100 THEN EXIT DO
LOOP
FOR n = 1 TO 21: PRINT Array$(n): NEXT
CLOSE #1
DO
  DO WHILE _MOUSEINPUT
    IF row >= 0 THEN row = row + _MOUSEWHEEL ELSE row = 0  'prevent under scrolling
    IF row > inputcount - 20 THEN row = inputcount - 20    'prevent over scrolling
    IF prevrow <> row THEN 'look for a change in row value
      IF row > 0 AND row <= inputcount - 20 THEN
        CLS: LOCATE 2, 1
        FOR n = row TO row + 20
          PRINT Array$(n)
        NEXT
      END IF
    END IF
    prevrow = row 'store previous row value
  LOOP
LOOP UNTIL INKEY$ > "" 

Note: You will need a text file that is large enough for this example.

See Also