Processing Window Scrolling Messages

When processing the scrolling message, the user should set the painting offsets to reflect the new coordinate translations.

The following example shows how to handle the horizontal scrolling message:

// This is example asumes, that we have a valid LEAD paint handle and a valid 
// LEAD bitmap handle, and the user has initialzied the current horizontal 
// and vertical scrolling position variables 
BITMAPHANDLE g_PaintBitmap ; 
RECT                       g_rcBitmapView ; 
int                             g_nHScrollPos ; 
int                             g_nVScrollPos ; 
L_VOID OnHScroll ( HWND hWnd, HWND hWndCtl, L_UINT nCode, L_INT nPos ) 
{ 
   SCROLLINFO si ; 
   PAINTXFORM PntXForm ; 
   UNREFERENCED_PARAMETER ( nPos ) ; 
   UNREFERENCED_PARAMETER ( hWndCtl ) ; 
   si.cbSize = sizeof ( SCROLLINFO ) ; 
   si.fMask  = SIF_ALL ; 
   GetScrollInfo ( hWnd, SB_HORZ, &si ) ; 
    
   g_nHScrollPos = si.nPos ; 
   switch ( nCode ) 
   { 
      case SB_LINELEFT: 
      si.nPos -= 1 ; 
      break ; 
       
      case SB_LINERIGHT: 
      si.nPos += 1 ; 
      break ; 
       
      case SB_PAGELEFT: 
      si.nPos -= si.nPage ; 
      break ; 
       
      case SB_PAGERIGHT: 
      si.nPos += si.nPage ; 
      break ; 
       
      case SB_THUMBTRACK: 
      si.nPos = si.nTrackPos ; 
      break ; 
       
default: 
      break ; 
   } 
   si.fMask = SIF_POS ; 
   SetScrollInfo ( hWnd, SB_HORZ, &si, TRUE ) ; 
   GetScrollInfo ( hWnd, SB_HORZ, &si ) ; 
    
   if ( si.nPos != g_nHScrollPos ) 
   { 
      // update screen. 
      OffsetRect ( &g_rcBitmapView, ( g_nHScrollPos - si.nPos ), 0 ) ; 
      ScrollWindow ( hWnd, ( g_nHScrollPos - si.nPos ), 0, NULL, NULL ) ; 
      g_nHScrollPos = si.nPos ; 
      UpdateWindow ( hWnd ) ; 
       
      // set Painting Transformation. 
      PntXForm.nZoom    = 100 ; 
      PntXForm.nXOffset = - g_rcBitmapView.left ; 
      PntXForm.nYOffset = - g_rcBitmapView.top ; 
      L_PntSetTransformation ( g_pPaintHandle, &PntXForm ) ; 
   } 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.