Processing the WM_HSCROLL and WM_VSCROLL messages

When processing the scrolling message for a window that owns a container associated with an automation handle, the user must set the container offsets. This can be done using L_ContainerSetOffset.

The following example shows how to do this for the WM_SIZE message:

static L_VOID OnSize 
( 
HWND hWnd, 
pCONTAINERHANDLE pContainer, 
pBITMAPHANDLE pBitmap, 
LPRECT prcView, 
L_INT cx, 
L_INT cy, 
L_INT nZoom, 
L_INT *pnHScroll, /*last horizontal scroll position*/ 
L_INT *pnVScroll  /*last vertical scroll position*/ 
) 
{ 
   SCROLLINFO si; 
   L_INT      nXOffset, nYOffset; 
   if (NULL != pBitmap && pBitmap->Flags.Allocated) 
   { 
      si.cbSize = sizeof(SCROLLINFO); 
      si.fMask = SIF_ALL; 
      // vertical scroll. 
      GetScrollInfo(hWnd, SB_VERT, &si); 
      si.nMin = 0; 
      si.nMax = BITMAPHEIGHT(pBitmap); 
      si.nPage = MulDiv(cy, 100, nZoom); 
      SetScrollInfo(hWnd, SB_VERT, &si, TRUE); 
      GetScrollInfo(hWnd, SB_VERT, &si); 
      *pnVScroll = si.nPos; 
      // horizontal scroll 
      GetScrollInfo(hWnd, SB_HORZ, &si); 
      si.nMin = 0; 
      si.nMax = BITMAPWIDTH(pBitmap); 
      si.nPage = MulDiv(cx, 100, nZoom); 
      SetScrollInfo(hWnd, SB_HORZ, &si, TRUE); 
      GetScrollInfo(hWnd, SB_HORZ, &si); 
      *pnHScroll = si.nPos; 
   } 
   else 
   { 
      si.cbSize = sizeof(SCROLLINFO); 
      si.fMask = SIF_RANGE; 
      si.nMin = 0; 
      si.nMax = 0; 
      SetScrollInfo(hWnd, SB_VERT, &si, TRUE); 
      SetScrollInfo(hWnd, SB_HORZ, &si, TRUE); 
      *pnHScroll = 0; 
      *pnVScroll = 0; 
   } 
   // set the painting rectangle. 
   SetRect(prcView, 0, 0, BITMAPWIDTH(pBitmap), BITMAPHEIGHT(pBitmap)); 
   if (nZoom < 100) 
   { 
      nXOffset = MulDiv(*pnHScroll, 100, nZoom); 
      nYOffset = MulDiv(*pnVScroll, 100, nZoom); 
   } 
   else 
   { 
      nXOffset = *pnHScroll; 
      nYOffset = *pnVScroll; 
   } 
   OffsetRect(prcView, -nXOffset, -nYOffset); 
   prcView->left = MulDiv(prcView->left, nZoom, 100); 
   prcView->top = MulDiv(prcView->top, nZoom, 100); 
   prcView->right = MulDiv(prcView->right, nZoom, 100); 
   prcView->bottom = MulDiv(prcView->bottom, nZoom, 100); 
   L_ContainerSetOffset(pContainer, -prcView->left, -prcView->top, 0); 
} 

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

LEADTOOLS Container and Automation C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.