L_SetMagGlassOwnerDrawCallback

#include "l_bitmap.h"

L_LTDIS_API L_INT L_SetMagGlassOwnerDrawCallback (hWnd, pfnCallback, pUserData)

L_HWND hWnd;

handle to a window

MAGGLASSOWNERDRAWCALLBACK pfnCallback;

callback function to set

L_VOID* pUserData;

pointer to more parameters for the callback

Sets a callback function, which lets the user provide custom magnifying glass rendering.

Parameter

Description

hWnd

Handle of the window to which the magnifying glass is attached.

pfnCallback

Callback function which be called every time the Magnifying Glass needs to be repainted.

 

The callback function must adhere to the function prototype described in MAGGLASSOWNERDRAWCALLBACK function.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

If a user-defined callback function is set by calling L_SetMagGlassOwnerDrawCallback, then after L_StartMagGlass is called and the Magnifying Glass paints itself to the DC, but before the Magnifying Glass is displayed on the screen, the user can change what is in the DC, through the user-defined callback function. This allows the user to provide custom rendering of the Magnifying Glass. For example, this feature lets you render magnified annotations, which may be overlaid on the currently displayed image, or just simply override what is currently in the Magnifying Glass display area.

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

L_StartMagGlass, L_StopMagGlass, L_UpdateMagGlassShape, L_UpdateMagGlass, MAGGLASSOWNERDRAWCALLBACK, L_SetMagGlassPaintOptions, L_ShowMagGlass, L_SetMagGlassPos, L_UpdateMagGlassBitmap, L_CreateZoomView, L_GetZoomViewProps, L_UpdateZoomView, L_DestroyZoomView, L_GetZoomViewsCount, L_WindowHasZoomView, ZOOMVIEWPROPS

Topics:

Using the Magnifying Glass

 

Raster Image Functions: Displaying Images

 

Using the Zoom View

Example

NOTE, this is NOT a complete example! This is an excerpt from the ANNOTATION Demo program. For the complete code, refer to ANNOTATE.C.

/*<struct>*/ 
#ifdef LET_DEFINE 
typedef struct _MAGCHILDDATA 
{ 
   int cxClient;              /* width of client area */ 
   int cyClient;              /* height of client area */ 
   int nHScrollPos;           /* x scroll position */ 
   int nVScrollPos;           /* y scroll position */ 
   int nHScrollMax;           /* maximum x scroll position */ 
   int nVScrollMax;           /* maximum y scroll postion */ 
   int nHScrollStep;          /* x scroll step value */ 
   int nVScrollStep;          /* y scroll step value */ 
   BOOL bThumbTrack; 
   BOOL fFitImage; 
   int nZoom; 
   RECT rcView; 
   RECT rcClient; 
   RECT rcWindow; 
   BITMAPHANDLE Bitmap; 
   HPALETTE hPalette; 
   HANNOBJECT hContainer; 
   HANNOBJECT hAutomation; 
   BOOL fInScroll; 
   BOOL  fShowLock; 
   HANNOBJECT  hRect; 
   HANNOBJECT  hEllipse; 
   BOOL  fCapture; 
   BOOL  fLeftButtonDown; 
   POINT pt0; 
   BOOL  bMagGlass; 
   L_INT nMagWidth; 
   L_INT nMagHeight; 
   L_INT nMagZoom; 
   L_BOOL bDoubleBuffer; 
   L_HANDLE hDoubleBuffer; 
} MAGCHILDDATA, FAR *LPMAGCHILDDATA; 
#endif 
/*</struct>*/ 
L_INT EXT_CALLBACK MagGlassOwnerDrawCallback(L_HWND     hWnd, 
HDC      hMemDC, 
L_INT32  nXPos, 
L_INT32  nYPos, 
LPRECT   pMagGlass, 
L_VOID*  pUserData) 
{ 
   UNREFERENCED_PARAMETER(hWnd); 
   LPMAGCHILDDATA pData = (LPMAGCHILDDATA) pUserData; 
   L_DOUBLE OffsetXOld, OffsetYOld; 
   L_DOUBLE OffsetX, OffsetY; 
   L_DOUBLE ScalarXOld, ScalarYOld; 
   L_DOUBLE ScalarX, ScalarY; 
   L_DOUBLE MagCenterX, MagCenterY; 
   L_DOUBLE BitmapX, BitmapY; 
   L_DOUBLE MagDestX, MagDestY; 
   RECT rc; 
   L_AnnPushFixedState(pData->hContainer, ANNFLAG_RECURSE | ANNFLAG_NOINVALIDATE); 
   L_AnnGetOffsetX(pData->hContainer, &OffsetXOld); 
   L_AnnGetOffsetY(pData->hContainer, &OffsetYOld); 
   L_AnnGetScalarX(pData->hContainer, &ScalarXOld); 
   L_AnnGetScalarY(pData->hContainer, &ScalarYOld); 
   MagCenterX = nXPos; 
   MagCenterY = nYPos; 
   BitmapX    = (L_DOUBLE)(MagCenterX-pData->rcView.left)/((L_DOUBLE)(pData->rcView.right - pData->rcView.left) /(L_DOUBLE)BITMAPWIDTH(&pData->Bitmap)); 
   BitmapY    = (L_DOUBLE)(MagCenterY-pData->rcView.top) /((L_DOUBLE)(pData->rcView.bottom - pData->rcView.top)/(L_DOUBLE)BITMAPHEIGHT(&pData->Bitmap)); 
   MagDestX   = BitmapX * ((L_DOUBLE)(pData->rcView.right - pData->rcView.left) /(L_DOUBLE)BITMAPWIDTH(&pData->Bitmap)) *  ((L_DOUBLE)pData->nMagZoom/100.0f); 
   MagDestY   = BitmapY * ((L_DOUBLE)(pData->rcView.bottom - pData->rcView.top)/(L_DOUBLE)BITMAPHEIGHT(&pData->Bitmap)) * ((L_DOUBLE)pData->nMagZoom/100.0f); 
   OffsetX    = ((L_DOUBLE)(pMagGlass->right - pMagGlass->left) /2.0f) - MagDestX; 
   OffsetY    = ((L_DOUBLE)(pMagGlass->bottom - pMagGlass->top)/2.0f) - MagDestY; 
   ScalarX    = (L_DOUBLE)(pData->rcView.right -  pData->rcView.left) / (L_DOUBLE)BITMAPWIDTH(&pData->Bitmap)  * ((L_DOUBLE)pData->nMagZoom/100.0f); 
   ScalarY    = (L_DOUBLE)(pData->rcView.bottom - pData->rcView.top)  / (L_DOUBLE)BITMAPHEIGHT(&pData->Bitmap) * ((L_DOUBLE)pData->nMagZoom/100.0f); 
   L_AnnSetOffsetX(pData->hContainer, OffsetX, ANNFLAG_NOINVALIDATE); 
   L_AnnSetOffsetY(pData->hContainer, OffsetY, ANNFLAG_NOINVALIDATE); 
   L_AnnSetScalarX(pData->hContainer, ScalarX, ANNFLAG_NOINVALIDATE); 
   L_AnnSetScalarY(pData->hContainer, ScalarY, ANNFLAG_NOINVALIDATE); 
   SetRect(&rc, 0, 0, pData->nMagWidth, pData->nMagHeight); 
   L_AnnDraw(hMemDC, &rc, pData->hContainer); 
   L_AnnSetOffsetX(pData->hContainer, OffsetXOld, ANNFLAG_NOINVALIDATE); 
   L_AnnSetOffsetY(pData->hContainer, OffsetYOld, ANNFLAG_NOINVALIDATE); 
   L_AnnSetScalarX(pData->hContainer, ScalarXOld, ANNFLAG_NOINVALIDATE); 
   L_AnnSetScalarY(pData->hContainer, ScalarYOld, ANNFLAG_NOINVALIDATE); 
   L_AnnPopFixedState(pData->hContainer, ANNFLAG_RECURSE | ANNFLAG_NOINVALIDATE); 
   return SUCCESS; 
} 
L_INT SetMagGlassOwnerDrawCallbackExample(L_HWND hwnd,LPMAGCHILDDATA pData) 
{ 
   L_INT nRet; 
   MAGGLASSOPTIONS Options; 
   nRet = L_AnnSetActiveState(pData->hAutomation, ANNACTIVE_DISABLED); 
   if(nRet != SUCCESS) 
      return nRet; 
   pData->nMagWidth = 200; 
   pData->nMagHeight = 200; 
   pData->nMagZoom = 200; 
   Options.uStructSize = sizeof(MAGGLASSOPTIONS); 
   Options.nWidth = pData->nMagWidth; 
   Options.nHeight         = pData->nMagHeight; 
   Options.nZoom           = pData->nMagZoom; 
   Options.clrPen          = RGB(0,0,0); 
   Options.hMagCursor      = NULL; 
   Options.clrBack         = RGB(128,128,128); 
   Options.bEllipse        = FALSE; 
   Options.nBorderSize     = 1; 
   Options.b3D             = FALSE; 
   Options.uPaintFlags     = 0; 
   Options.pMask           = NULL; 
   Options.uMaskCount      = 0; 
   Options.uMagGlassFlags  = CROSSHAIR_FINE; 
   Options.nCrosshair      = 1; 
   Options.bIgnoreRgn      = TRUE; 
   Options.bCenter         = TRUE; 
   nRet = L_StartMagGlass( 
   hwnd, 
   &pData->Bitmap, 
   &pData->rcView, 
   &Options, 
   NULL, 
   pData); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_SetMagGlassOwnerDrawCallback(hwnd, MagGlassOwnerDrawCallback, pData); 
   if(nRet != SUCCESS) 
      return nRet; 
   pData->bMagGlass = TRUE; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help