FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour fwh_20.03\source\classes\bitmap.prg
Posts: 109
Joined: Sun Nov 13, 2005 12:40 AM
fwh_20.03\source\classes\bitmap.prg
Posted: Mon Nov 10, 2025 01:10 AM

Hi everyone, I have a question. And respected Antonio Linares

fwh_20.03\source\classes\bitmap.prg ::ScrollDown() ::ScrollUp() ::PageUp() ::PageDown()

When executing the above functions while the image is zoomed in, they only move a small amount. What should I change to allow the image to scroll to the end ? Or, what is the solution?

FWH User

FWPPC User

FWLinux User
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: fwh_20.03\source\classes\bitmap.prg
Posted: Mon Nov 10, 2025 02:25 AM

Root cause of the scrolling issue when the image is zoomed in. There are two main problems:

Problem 1: Fixed scroll step sizes
The scroll step values (::nVStep and ::nHStep) are initialized to 1 and never scale with the zoom level. When you zoom in (e.g., nZoom = 2 or 3), the image dimensions increase proportionally, but the scroll step remains at 1 pixel, making scrolling extremely slow.

Problem 2: Incorrect bounds in scroll handlers
In the VScroll() and HScroll() methods, the SB_BOTTOM case sets ::nX = ::nXExtra() and ::nY = ::nYExtra(), but everywhere else in the code treats the lower bound as negative (-::nXExtra() and -::nYExtra()). This sign inconsistency prevents reaching the true end of the image.

Solution:

You need to make three changes in bitmap.prg:

1. Scale scroll steps with zoom - Modify the ScrollAdjust() method (around line 1072) to set the step sizes based on zoom:

Code (harbour): Select all Collapse
METHOD ScrollAdjust() CLASS TBitmap
   local nVisHeight, nVisWidth
   local lHor := .f., lVer := .f.

   nVisHeight = ::Super:nHeight()
   nVisWidth  = ::Super:nWidth()

   // Add these lines to scale steps with zoom:
   ::nVStep := Max( 1, Int( ::nZoom ) )
   ::nHStep := Max( 1, Int( ::nZoom ) )

   if ::lScroll .and. ! Empty( ::hBitmap ) .and. ::oVScroll != nil
      // ... rest of the method unchanged

2. Fix the vertical scroll end position - In the VScroll() method (around line 1008), change:

Code (harbour): Select all Collapse
case nScrollCode == SB_BOTTOM
   ::nX := -::nXExtra()  // Changed from ::nX = ::nXExtra()
   ::oVScroll:GoBottom()
   ::Refresh( .f. )

3. Fix the horizontal scroll end position - In the HScroll() method (around line 1054), change:

Code (harbour): Select all Collapse
case nScrollCode == SB_BOTTOM
   ::nY := -::nYExtra()  // Changed from ::nY = ::nYExtra()
   ::oHScroll:GoBottom()
   ::Refresh( .f. )

Optional Enhancement:
For even smoother scrolling, you could make the step size proportional to the visible area instead of just the zoom factor:

Code (harbour): Select all Collapse
::nVStep := Max( 1, Int( ::Super:nHeight() / 10 ) )
::nHStep := Max( 1, Int( ::Super:nWidth() / 10 ) )

This would make each scroll step move approximately 10% of the visible area, which provides a better user experience regardless of zoom level.

These changes will allow the image to scroll properly to the end when zoomed in, with scroll steps that scale appropriately with the zoom level.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 109
Joined: Sun Nov 13, 2005 12:40 AM
Re: fwh_20.03\source\classes\bitmap.prg
Posted: Mon Nov 10, 2025 04:08 PM

Thank you so much, it was really helpful

FWH User

FWPPC User

FWLinux User

Continue the discussion