home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2BAS.ZIP / SCROLMOD.BAS < prev    next >
BASIC Source File  |  1989-08-27  |  4KB  |  129 lines

  1. REM $INCLUDE: 'os2def.bi'
  2. REM $INCLUDE: 'pmbase.bi'
  3. REM $INCLUDE: 'opendlg.bi'
  4. REM $INCLUDE: 'winmisc.bi'
  5. REM $INCLUDE: 'wintrack.bi'
  6. REM $INCLUDE: 'gpibit.bi'
  7.  
  8. REM $INCLUDE: 'CAPTURE.INC'
  9.  
  10. '|***************************************************************************
  11. '|
  12. '| SCROLMOD.BAS:  Support module of CAPTURE.BAS
  13. '|
  14. '|***************************************************************************
  15. '| This module controls the Frame windows scroll bars.  If the scroll bar
  16. '| selected is enabled, this routine repositions the scroll bar position
  17. '| indicator and redisplays the portion of the bitmap that corresponds
  18. '| to the new scroll bar postions.
  19. '|***************************************************************************
  20. '|
  21. SUB ControlScrollBars(hwnd&, scrollbar%, mp2&) STATIC
  22. SHARED hbm&, hwndHorzScroll&, hwndVertScroll&
  23. DIM ptl AS POINTL
  24. '|
  25. '| Get current scroll bar positions and max values.
  26. '| SMBQUERYRANGE returns a LONG integer value, with the upper limit in
  27. '| the high word, and the lower limit in the low word.  Since the lower
  28. '| limit is always zero, only the upper limit is needed; Thus the value
  29. '| returned from SMBQUERYRANGE is shifted right 16 bits and assigned to
  30. '| an INTEGER (SHAORT)
  31. '|
  32.   Hpos% = WinSendMsg(hwndHorzScroll&, SBMQUERYPOS, 0, 0)
  33.   Hmax% = WinSendMsg(hwndHorzScroll&, SBMQUERYRANGE, 0, 0) \ 2 ^ 16
  34.   Vpos% = WinSendMsg(hwndVertScroll&, SBMQUERYPOS, 0, 0)
  35.   Vmax% = WinSendMsg(hwndVertScroll&, SBMQUERYRANGE, 0, 0) \ 2 ^ 16
  36. '|
  37. '| Determine portion of scroll bar that was selected
  38. '|
  39.   CALL BreakLong(mp2&, hcommand%, lowword%)
  40.   SELECT CASE scrollbar%
  41.   '|
  42.   '| Control Horizontal Scroll Bar
  43.   '|
  44.     CASE WMHSCROLL
  45.       SELECT CASE hcommand%
  46.         CASE SBLINELEFT
  47.           Hpos% = Hpos% - 1
  48.         CASE SBPAGELEFT
  49.           Hpos% = Hpos% - 10
  50.         CASE SBLINERIGHT
  51.           Hpos% = Hpos% + 1
  52.         CASE SBPAGERIGHT
  53.           Hpos% = Hpos% + 10
  54.         CASE SBSLIDERTRACK
  55.           Hpos% = lowword%
  56.           LHpos% = lowword%
  57.         CASE SBSLIDERPOSITION
  58.           Hpos% = LHpos%
  59.         CASE ELSE
  60.       END SELECT
  61.     '|
  62.     '| If Hpos% is outside range due to a PAGELEFT or PAGERIGHT
  63.     '| set to minimum or maximum value.
  64.     '|
  65.       IF Hpos% > Hmax% THEN Hpos% = Hmax%
  66.       IF Hpos% < 0 THEN Hpos% = 0
  67.     '|
  68.     '| Reset Scroll bar position indicator only if user is not sliding the
  69.     '| position indicator.
  70.     '|
  71.       IF hcommand% <> SBSLIDERTRACK THEN
  72.         bool& = WinSendMsg(hwndHorzScroll&,_
  73.                            SBMSETPOS,_
  74.                            MakeLong(0, Hpos%),_
  75.                            0)
  76.       END IF
  77.   '|
  78.   '| Control Vertical Scroll bar
  79.   '|
  80.     CASE WMVSCROLL
  81.       SELECT CASE hcommand%
  82.         CASE SBLINEUP
  83.           Vpos% = Vpos% - 1
  84.         CASE SBPAGEUP
  85.           Vpos% = Vpos% - 10
  86.         CASE SBLINEDOWN
  87.           Vpos% = Vpos% + 1
  88.         CASE SBPAGEDOWN
  89.           Vpos% = Vpos% + 10
  90.         CASE SBSLIDERTRACK
  91.           Vpos% = lowword%
  92.           LVpos% = lowword%
  93.         CASE SBSLIDERPOSITION
  94.           Vpos% = LVpos%
  95.         CASE ELSE
  96.       END SELECT
  97.     '|
  98.     '| If Vpos% is outside range due to a PAGEDOWN or PAGEUP
  99.     '| set to minimum or maximum value.
  100.     '|
  101.       IF Vpos% > Vmax% THEN Vpos% = Vmax%
  102.       IF Vpos% < 0 THEN Vpos% = 0
  103.     '|
  104.     '| Reset Scroll bar position indicator only if user is not sliding the
  105.     '| position indicator.
  106.     '|
  107.       IF hcommand% <> SBSLIDERTRACK THEN
  108.         bool& = WinSendMsg(hwndVertScroll&,_
  109.                            SBMSETPOS,_
  110.                            MakeLong(0, Vpos%),_
  111.                            0)
  112.       END IF
  113.   END SELECT
  114. '|
  115. '| Get a presentation space to draw bitmap, and calculate from
  116. '| new scroll bar positions the portion of the bitmap to display
  117. '|
  118.   hps& = WinGetPS(hwnd&)
  119.   ptl.x = 0
  120.   ptl.y = 0
  121.   IF WinIsWindowEnabled(hwndHorzScroll&) THEN ptl.x = -Hpos%
  122.   IF WinIsWindowEnabled(hwndVertScroll&) THEN ptl.y =  Vpos% - Vmax%
  123.   bool% = WinDrawBitmap(hps&, hbm&, 0,_
  124.                         MakeLong(VARSEG(ptl), VARPTR(ptl)),_
  125.                         CLRNEUTRAL, CLRBACKGROUND, DBMNORMAL)
  126.   bool% = WinReleasePS(hps&)
  127. END SUB
  128.  
  129.