Gets the toolkit's current transformation information.
#include "Ltwrappr.h"
L_INT LRasterPaint::GetTransformation(pXForm)
Pointer to a PAINTXFORM structure to be updated with the current painting transformations.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes |
The transformation information is used for translating from external coordinates, such as mouse position, to the device context (DC) and/or bitmap coordinates.
L_INT LRasterPaint_GetTransformationExample( LRasterPaint &rstp, CWnd* pWnd, LBitmap* pBitmap )
{
L_INT nRet;
CDC* pDC = pWnd->GetDC( ) ;
RECT rcView ;
RECT rcShapeRect ;
PAINTXFORM PntXForm ;
RECT rcDCExtents ;
/* Get the Current painting transformations */
nRet = rstp.GetTransformation ( &PntXForm ) ;
if(nRet != SUCCESS)
return nRet;
rcView.left = - PntXForm.nXOffset ;
rcView.top = - PntXForm.nYOffset ;
rcView.right = rcView.left + MulDiv ( pBitmap->GetWidth ( ), PntXForm.nZoom, 100 ) ;
rcView.bottom = rcView.top + MulDiv ( pBitmap->GetHeight ( ), PntXForm.nZoom, 100 ) ;
/* paint the bitmap */
pBitmap->Paint( )->SetDC( pDC->m_hDC );
pBitmap->SetDstRect( &rcView );
pBitmap->Paint( )->PaintDC();
/* Set the rectangle coordinates with respect to the DC dimensions*/
SetRect ( &rcShapeRect, 10, 10, 150, 150 ) ;
/* Get the destination DC dimensions */
pWnd->GetClientRect ( &rcDCExtents ) ;
/* Set the toolkit user DC extents */
nRet = rstp.SetDCExtents ( &rcDCExtents ) ;
if(nRet != SUCCESS)
return nRet;
/* Use the current shape properties to draw a rectangle to DC (hDC) */
nRet = rstp.DrawShapeRectangle ( pDC->m_hDC, &rcShapeRect ) ;
if(nRet != SUCCESS)
return nRet;
/* Release the device context */
pWnd->ReleaseDC( pDC ) ;
return SUCCESS ;
}