LContainer::SetOffset

Summary

Sets the container coordinates offset values.

Syntax

#include "Ltwrappr.h"

L_INT LContainer::SetOffset (nXOffset, nYOffset, nZOffset = 0)

Parameters

L_INT nXOffset

The offset in the X direction of the external representation.

L_INT nYOffset

The offset in the Y direction of the external representation.

L_INT nZOffset

The offset in the Z direction of the external representation. Default value is 0.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The user should set the offset every time the window that owns the container is scrolled.

When assigning an external representation to the container every point (Xa, Ya) in the an external representation is transformed by the container to the point (Xc, Yc) by using the following steps:

  1. Add offsets

    • Xb = Xa + nXOffset
  2. Multiply by scalars

    • Xc = (Xb \* nXScalarNum) / nXScalarDen
    • Yc = (Yb \* nYScalarNum) / nYScalarDen
    • Yb = Ya + nYOffset

The default offsets values are nXOffset = 0, nYOffset = 0 and nZOffset = 0.

Required DLLs and Libraries

See Also

Functions

Topics

Example

This will show to modify the container coordinates offset values to reflect the changes in the window offset.
The example assumes that there is an already initialized toolbar handle.

LContainer lCont ; 
 
 
 
/*static*/ L_VOID OnSize  
 
(  
 
   HWND hWnd, 
 
   pBITMAPHANDLE pBitmap,  
 
   LPRECT prcView, 
 
   L_INT cx,  
 
   L_INT cy,  
 
   L_INT nZoom,  
 
   L_INT *pnHScroll,  
 
   L_INT *pnVScroll  
 
) 
 
{ 
 
   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 rectangel. 
 
   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 ) ; 
 
   lCont.SetOffset ( - prcView->top, 0 ) ; 
 
} 

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

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