L_ShowMagGlass

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_ShowMagGlass(hWnd, bShow)

HWND hWnd;

/* handle to a window */

L_BOOL bShow;

/* flag that indicates whether to show or hide the Magnifying Glass */

Shows or hides the magnifying glass on the screen.

Parameter

Description

hWnd

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

bShow

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

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 bShow set to TRUE when the left mouse button is pressed to show the magnifying glass. It can be called with bShow 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

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

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_StartMagGlass, L_StopMagGlass, 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

/* 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. */

.


L_BOOL   bLeftButton=FALSE; 
HCURSOR  hMagGlassCursor=NULL; 




L_VOID StartMagnifyingGlass(HWND hWnd, pBITMAPHANDLE pBitmap, pBITMAPHANDLE pUpdateBitmap, RECT* prcView) 
{
   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); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
      return; 
   }

   // 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); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
      return; 
   }

   hMagGlassCursor = LoadCursor(hInst, MAKEINTRESOURCE(IDC_MAGGLASS_CURSOR)); 
}

L_BOOL Child_OnSetCursor(HWND hWnd, 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(HWND hWnd, L_BOOL fDoubleClick, L_INT x, L_INT y, L_UINT 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); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
      return; 
   }

   nRet = L_ShowMagGlass(hWnd, TRUE); 
   if (nRet != SUCCESS) 
   {
      wsprintf(szMsg, TEXT("Error Displaying Magnifying Glass, Error: %d"), nRet); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
      return; 
   }

   bLeftButton = TRUE; 
}

L_VOID Child_OnMouseMove(HWND hWnd, L_INT x, L_INT y, L_UINT 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); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
   }
}

L_VOID Child_OnLButtonUp(HWND hWnd, L_INT x, L_INT y, L_UINT 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); 
      MessageBox(hWnd, szMsg, TEXT("Error"), MB_ICONEXCLAMATION | MB_OK); 
   }

   ShowCursor(TRUE); 

   bLeftButton = FALSE; 
}