Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_CreatePanWindow

Show in webframe

#include "l_bitmap.h"

L_LTDIS_API L_INT L_CreatePanWindow(hWndParent, pBitmap, ulDisplayFlags, nLeft, nTop, nWidth, nHeight, pszClassName, hIcon, hCursor, bSysMenu, pfnPanCallback, pUserData)

L_HWND hWndParent;

/* handle to owner of PanWindow */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT ulDisplayFlags;

/* display flags */

L_INT nLeft;

/* x coordinate for PanWindow */

L_INT nTop;

/* y coordinate for PanWindow */

L_INT nWidth;

/* requested client width */

L_INT nHeight;

/* requested client height */

L_TCHAR * pszClassName;

/* class name for PanWindow */

L_HICON hIcon;

/* handle to icon for PanWindow */

L_HCURSOR hCursor;

/* handle to cursor for PanWindow */

L_BOOL bSysMenu;

/* system menu flag */

PANWNDCALLBACK pfnPanCallback;

/* notification callback function */

L_VOID* pUserData;

/* pointer to more parameters for the callback */

Creates the Pan Window and associates it with hWndParent.

Parameter

Description

hWndParent

Handle to the main window, which will be displaying pBitmap. This window will not be the parent, but will be associated with the PanWindow.

pBitmap

Pointer to the bitmap handle referencing the bitmap to be displayed in the PanWindow.

ulDisplayFlags

Flags which determine how the image is painted in the Pan Window. For values, refer to Flags for the L_SetDisplayMode Function.

nLeft

X coordinate for the origin of the Pan Window.

nTop

Y coordinate for the origin of the Pan Window.

nWidth

Requested width of the Pan Window's client area. The actual width will depend on the aspect ratio of the image pointed to by pBitmap and the values passed for nWidth and nHeight.

nHeight

Requested height of the Pan Window's client area. The actual height will depend on the aspect ratio of the image pointed to by pBitmap and the values passed for nWidth and nHeight.

pszClassName

Character string containing the class name for which to register the Pan Window. This must be a valid string, and should be related to your application, to avoid conflicting with an existing registered window class name.

hIcon

Handle to the icon to use for the Pan Window. Pass NULL for no icon.

hCursor

Handle to the cursor to use for the Pan Window.

bSysMenu

TRUE to include the system menu on the Pan Window. FALSE to omit it.

pfnPanCallback

Callback function for doing custom painting and getting notification of Pan Rect updates.

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

This function creates the Pan Window and associates it with hWndParent.

The Pan Windows width and height will be adjusted to account for the aspect ratio of the image pointed to by pBitmap. You must specify a PANWNDCALLBACK callback function to do custom painting or be notified of interactive Pan Rect updates. To position the Pan Rect, call the L_UpdatePanWindow function. You must use L_DestroyPanWindow to destroy the Pan Window and all data associated with it.

Note: the calling application is responsible for coordinating the Pan Window's Pan Rect and the actual display rect of the main window.

Call L_UpdatePanWindow to make the window visible, and set the Pan Rect.

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, Linux.

See Also

Functions:

L_UpdatePanWindow, L_DestroyPanWindow, PANWNDCALLBACK

Example

Add the following code to the end of SCRLZOOM.C : The following provides a quick and easy method for viewing a Pan Window. To make this sample easier to drop into place, a number of globals have been used. For the full sample code for the Pan Window, refer to CHILD.C of the DEMO example program.

//Add the following code to SCRLZOOM.C in the SCRLZOOM demo.
/************************************************************************
#ifdef WIN32
#define PANWINDOW_CLASS  TEXT("L_PANWINDOW_32")
#else
#define PANWINDOW_CLASS  TEXT("L_PANWINDOW_16")
#endif

FARPROC  lpfn;
L_UINT32 ulFlags = 0;
 L_HWND    ghPanWindow;
L_BOOL   bUpdatePan = FALSE;
L_BOOL   bPanWindow = FALSE;
L_INT    gnZoom = 100;
L_HWND     ghBitmapWnd;
L_BOOL   fFitImage = FALSE;

L_VOID CreatePanWindowExample(L_HWND hWnd);
L_VOID EXT_CALLBACK PanWindowCallback(L_HWND hPanWindow, L_HWND hWndParent, L_UINT uMsg, LPRECT prcPan, L_VOID  *pUserData);

// Add the following code to the switch statement in MainWndProc in SCRLZOOM.C, right after HANDLE_MSG (hWnd, WM_DESTROY, Window_OnDestroy);

   case WM_KEYDOWN:
      CreatePanWindowExample(hWnd);

// Add the following code immediately following the call to L_PaintDC (hDC, &Data.Bitmap, NULL, NULL, &Data.rcView, &ps.rcPaint, SRCCOPY); in the Window_OnPaint function in SCRLZOOM.C :
L_UpdatePanWindow(ghPanWindow, &Data.Bitmap, ulFlags, RGB(255, 0, 0), TEXT("Pan Window"), &Data.rcView);

// Add the following code immediately before PostQuitMessage(0); in WIndow_OnDestroy in SCRLZOOM.C :
bPanWindow = FALSE;
if (ghPanWindow)
     L_DestroyPanWindow(ghPanWindow);

// Add the following code to the end of SCRLZOOM.C :
L_VOID CreatePanWindowExample(L_HWND hWnd)
{
   // if no PanWindow, create one
   if (bPanWindow == 0)
   {
      bUpdatePan = TRUE;
      ulFlags = DISPLAYMODE_SCALETOGRAY;
      lpfn = MakeProcInstance((FARPROC)PanWindowCallback, hInst);
      L_CreatePanWindow(hWnd, &Data.Bitmap, ulFlags, 0, 0, 150, 150, PANWINDOW_CLASS, NULL, NULL, TRUE, (PANWNDCALLBACK)lpfn, NULL);
      ghBitmapWnd = hWnd;
      L_UpdatePanWindow(ghPanWindow, &Data.Bitmap, ulFlags, RGB(255, 0, 0), TEXT("Pan Window"), &Data.rcView);
      // Free the callback function
      FreeProcInstance((FARPROC) PanWindowCallback);
   }
   return;
}

L_VOID EXT_CALLBACK PanWindowCallback(L_HWND      hPanWindow,
                                      L_HWND      hWndParent,
                                      L_UINT    uMsg,
                                      LPRECT    prcPan,
                                      L_VOID*   pUserData)
{
   POINT Pt;
   L_INT dy, dx;

   // This adjusts the gnZoom value when the main window is zoomed.
   if (Data.nScalar > 0)
      gnZoom = (Data.nScalar + 1) * 100;
   else if (Data.nScalar < 0)
      gnZoom = (Data.nScalar - 1) * 100;
   else if (Data.nScalar == 0)
      gnZoom = 100;

   switch(uMsg)
   {
   case PANWIN_CREATED:
      ghPanWindow = hPanWindow;
      break;

   case PANWIN_UPDATED:
      Pt.x = prcPan->left;
      Pt.y = prcPan->top;

      dx = Data.rcView.right - Data.rcView.left;
      dy = Data.rcView.bottom - Data.rcView.top;

      Data.rcView.left   = -min(Data.nHScrollMax, MulDiv(Pt.x, gnZoom, 100));
      Data.rcView.right  = Data.rcView.left + dx;
      Data.rcView.top    = -min(Data.nVScrollMax, MulDiv(Pt.y, gnZoom, 100));
      Data.rcView.bottom = Data.rcView.top + dy;
      bUpdatePan         = FALSE;
      Data.nHScrollPos   = -Data.rcView.left;
      Data.nVScrollPos   = -Data.rcView.top;

      SetScrollPos(ghBitmapWnd, SB_HORZ, Data.nHScrollPos, TRUE);
      SetScrollPos(ghBitmapWnd, SB_VERT, Data.nVScrollPos, TRUE);
      InvalidateRect(ghBitmapWnd, NULL, FALSE);
      UpdateWindow(ghBitmapWnd);
      break;

   case PANWIN_DESTROYED:
      hPanWindow = NULL;
      bPanWindow = FALSE;
      break;
   }
   return;
}
*************************************************************/
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.