L_ShowMagGlass

Summary

Shows or hides the magnifying glass on the screen.

Syntax

#include "l_bitmap.h"

L_LTDIS_API L_INT L_ShowMagGlass(hWnd, bShowMagGlass)

Parameters

L_HWND hWnd

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

L_BOOL bShowMagGlass

Flag that indicates whether to show or hide the magnifying glass. Possible values are:

Value Meaning
TRUE Show the magnifying glass.
FALSE Hide the magnifying glass.

Returns

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

Comments

The function is used to control the display of the magnifying glass on the screen. Since the user is responsible for displaying the magnifying glass and moving it on the screen in a manual update, this function is used in conjunction with L_SetMagGlassPos function.

This function can be called with bShowMagGlass set to TRUE when the left mouse button is pressed to show the magnifying glass. It can be called with bShowMagGlass set to FALSE when the left mouse button is released to hide the magnifying glass.

Note: This function can be used only if the MAGGLASS_MANUAL_UPDATE flag was set when calling L_StartMagGlass function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example starts the Magnifying Glass in the Manual Update mode,
then calls the necessary functions such like L_SetMagGlassPos and
L_ShowMagGlass to handle the painting of the Magnifying Glass.

static L_BOOL   bLeftButton = FALSE; 
static HCURSOR  hMagGlassCursor = NULL; 
 
#define IDC_MAGGLASS_CURSOR 1234 
 
L_INT StartMagnifyingGlassExample(L_HWND hWnd, 
   pBITMAPHANDLE pBitmap, 
   pBITMAPHANDLE pUpdateBitmap, 
   L_RECT * prcView, 
   HINSTANCE hInst) 
{ 
   L_INT             nRet; 
   L_TCHAR           szMsg[256] = TEXT(""); 
   MAGGLASSOPTIONS   MagGlassOpt; 
 
   // Starting the Magnifying Glass 
   memset(&MagGlassOpt, 0, sizeof(MAGGLASSOPTIONS)); 
   MagGlassOpt.uStructSize = sizeof(MAGGLASSOPTIONS); 
   MagGlassOpt.nWidth = 100; 
   MagGlassOpt.nHeight = 100; 
   MagGlassOpt.nZoom = 400; 
   MagGlassOpt.clrPen = RGB(255, 0, 0); 
   MagGlassOpt.hMagCursor = NULL; 
   MagGlassOpt.clrBack = RGB(128, 128, 128); 
   MagGlassOpt.bEllipse = FALSE; 
   MagGlassOpt.nBorderSize = 1; 
   MagGlassOpt.b3D = TRUE; 
   MagGlassOpt.uPaintFlags = 0; 
   MagGlassOpt.pMask = NULL; 
   MagGlassOpt.uMaskCount = 0; 
   MagGlassOpt.nCrosshair = CROSSHAIR_FINE; 
   MagGlassOpt.bIgnoreRgn = TRUE; 
   MagGlassOpt.bCenter = TRUE; 
   MagGlassOpt.uMagGlassFlags = MAGGLASS_MANUAL_UPDATE; 
 
   nRet = L_StartMagGlass(hWnd, pBitmap, prcView, &MagGlassOpt, NULL, NULL); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Starting the Magnifying Glass, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
      return nRet; 
   } 
 
   // Updating the Magnifying Glass bitmap with another bitmap that has the  
   // same width and height.  
   nRet = L_UpdateMagGlassBitmap(hWnd, pUpdateBitmap, TRUE); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Trying to update the Magnifying Glass bitmap, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
      return nRet; 
   } 
 
   nRet = L_UpdateMagGlassPaintFlags(hWnd, DISPLAYMODE_SCALETOGRAY); //enable ScaleToGray for MagGlass 
 
   hMagGlassCursor = LoadCursor(hInst, MAKEINTRESOURCE(IDC_MAGGLASS_CURSOR)); 
 
   return nRet; 
} 
 
L_BOOL Child_OnSetCursor(L_HWND hWnd, L_HWND hWndCursor, L_UINT codeHitTest, L_UINT msg) 
{ 
   if (codeHitTest != HTCLIENT) 
      return (FORWARD_WM_SETCURSOR(hWnd, hWndCursor, codeHitTest, msg, DefMDIChildProc)); 
 
   if (L_WindowHasMagGlass(hWnd) && !bLeftButton) 
      SetCursor(hMagGlassCursor); 
 
   return TRUE; 
} 
 
L_VOID Child_OnLButtonDown(L_HWND hWnd, L_BOOL fDoubleClick, L_INT x, L_INT y, L_UINT keyFlags) 
{ 
   UNREFERENCED_PARAMETER(fDoubleClick); 
   UNREFERENCED_PARAMETER(x); 
   UNREFERENCED_PARAMETER(y); 
   UNREFERENCED_PARAMETER(keyFlags); 
 
   L_INT   nRet; 
   L_TCHAR szMsg[256] = TEXT(""); 
 
   if (!L_WindowHasMagGlass(hWnd)) 
      return; 
 
   SetCapture(hWnd); 
   ShowCursor(FALSE); 
 
   nRet = L_SetMagGlassPos(hWnd, x, y); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Displaying Magnifying Glass, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
      return; 
   } 
 
   nRet = L_ShowMagGlass(hWnd, TRUE); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Displaying Magnifying Glass, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
      return; 
   } 
 
   bLeftButton = TRUE; 
} 
 
L_VOID Child_OnMouseMove(L_HWND hWnd, L_INT x, L_INT y, L_UINT keyFlags) 
{ 
   UNREFERENCED_PARAMETER(x); 
   UNREFERENCED_PARAMETER(y); 
   UNREFERENCED_PARAMETER(keyFlags); 
 
   L_INT   nRet; 
   L_TCHAR szMsg[256] = TEXT(""); 
 
   if (!L_WindowHasMagGlass(hWnd) || !bLeftButton) 
      return; 
 
   nRet = L_SetMagGlassPos(hWnd, x, y); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Moving Magnifying Glass, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
   } 
} 
 
L_VOID Child_OnLButtonUp(L_HWND hWnd, L_INT x, L_INT y, L_UINT keyFlags) 
{ 
   UNREFERENCED_PARAMETER(x); 
   UNREFERENCED_PARAMETER(y); 
   UNREFERENCED_PARAMETER(keyFlags); 
 
   L_INT   nRet; 
   L_TCHAR szMsg[256] = TEXT(""); 
 
   if (!L_WindowHasMagGlass(hWnd) || !bLeftButton) 
      return; 
 
   ReleaseCapture(); 
 
   nRet = L_ShowMagGlass(hWnd, FALSE); 
   if (nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error Hiding Magnifying Glass, Error: %d"), nRet); 
      _tprintf(_T("%s"), szMsg); 
   } 
 
   ShowCursor(TRUE); 
 
   bLeftButton = FALSE; 
} 

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

LEADTOOLS Raster Imaging C API Help

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