LImageViewer::Create

#include "ltwrappr.h"

L_INT LImageViewer::Create (hWndParent, lpRect, uFlags);

HWND hWndParent;

handle to the parent window

RECT * lpRect;

pointer to a structure

L_UINT uFlags;

reserved for future use

Creates a container, which is a window that contains a number of child windows (cells). Each cell can hold a single image or a list of images.

Parameter Description
hWndParent Handle to the parent or owner window of the container window being created.
lpRect Pointer to a RECT structure that contains the initial bounds of the container window. The values in this structure are specified in pixels and are relative to the parent window.
uFlags Flag that determines whether the control will use the old way or the new way to handle the palette. For more information see LImageViewerCell::HandlePalette. Possible values are:
  CONTAINER_DONTHANDLEPALETTE [0] Palette handled automatically. Fast and efficient. For 16-bit and higher display systems, no additional code or action for palette handling is required to run demos.
  CONTAINER_HANDLEPALETTE [1] For 8-bit display systems (such as 256-color monitors), handles palette messages and sends them through LImageViewerCell::HandlePalette. Slower, but allows demos to run on 8-bit monitors.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function will create a window that will hold the container. This container window serves as the "image viewer".

Each container has numerous characteristics, such as the number of rows, the number of columns, border colors, background colors, cursors, etc. that can be set programmatically using LImageViewer::SetProperties. To get the current characteristics of a specific container, call LImageViewer::GetProperties.

A container can also have certain actions, either standard or user-defined, associated with it. These actions are applied either through the mouse or through keystroke combinations. For more information, refer to Applying Actions.

When a container window is viewed in an application, 3-dimensional thick dark lines called splitters are visible to the right of the container window and at the bottom of the container window. In an application, these allow the user to dynamically change the number of rows and columns used to display the images, by dragging an extra splitter into position. The size of the cells can also be modified by moving existing splitters.

While the user drags the splitter using the left mouse button, an inverted line appears showing the new position. If the user clicks the right mouse button while dragging the splitter, this will cancel the dragging.

The maximum number of rows allowed is 4. The maximum number of columns is 8. If the image viewer contains the maximum number of rows, the extra splitter at the bottom of the image viewer will disappear. Likewise, if the image viewer contains the maximum number of columns, the extra splitter to the right of the image viewer will disappear.

When the container created by this function is no longer needed, free the container and any associated memory by calling LImageViewer::Destroy. For every call to LImageViewer::Create there must be a call to LImageViewer::Destroy.

Required DLLs and Libraries

LTIVW

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

See Also

Functions:

LImageViewer::GetWindowHandle, LImageViewer::Destroy, LImageViewer::SetProperties, LImageViewer::GetProperties, Class Members

Topics:

Using the Image Viewer

 

Window Control/Image Viewer Functions: Using the Image Viewer

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
#define RECT_HEIGHT(lpRect)      ((lpRect)->bottom - (lpRect)->top) 
#define SELECT_FONT(hDC, hFont)  ((HFONT) SelectObject((hDC), (HGDIOBJ)(HFONT)(hFont))) 
LImageViewer* gImageViewer = NULL; 
class LImageViewerChild2 :public LImageViewerCell 
{ 
   L_INT ActionCallBack(HBITMAPLIST * phBitmapList, 
   L_UINT uCount, 
   L_INT nAction, 
   L_UINT uMessage, 
   WPARAM wParam, 
   POINT * ptMousePos); 
   virtual L_INT TagCallBack(HWND hCellWnd, L_INT nCellIndex, HDC hDC, RECT * lpRect); 
} ; 
L_INT LImageViewerChild2::TagCallBack(HWND hCellWnd, L_INT nCellIndex, HDC hDC, RECT * lpRect) 
{ 
   UNREFERENCED_PARAMETER(hCellWnd); 
   if (nCellIndex == 0) 
   { 
      // draw an overlay with italic font 
      static LOGFONT lf; 
      HFONT hFont, hOldFont; 
      lf.lfHeight = RECT_HEIGHT(lpRect); 
      lf.lfItalic = TRUE; 
      wsprintf(lf.lfFaceName, TEXT("Times new Roman\0")); 
      SetTextAlign(hDC, TA_BOTTOM | TA_RIGHT); 
      SetTextColor(hDC, RGB(255, 255, 255)); 
      hFont = CreateFontIndirect(&lf); 
      hOldFont = SELECT_FONT(hDC, hFont); 
      TextOut(hDC, lpRect->right, lpRect->bottom, TEXT("Owner Text"), 10); 
   } 
   return TRUE; 
} 
L_INT LImageViewerChild2::ActionCallBack(HBITMAPLIST * phBitmapList, L_UINT uCount, 
L_INT nAction, L_UINT uMessage, WPARAM wParam, 
POINT * ptMousePos) 
{ 
   UNREFERENCED_PARAMETER(phBitmapList); 
   UNREFERENCED_PARAMETER(uCount); 
   UNREFERENCED_PARAMETER(nAction); 
   UNREFERENCED_PARAMETER(wParam); 
   UNREFERENCED_PARAMETER(ptMousePos); 
   L_INT    nRet = 0 ; 
   L_UINT   uRow = 0 ; 
   switch(uMessage) 
   { 
      case WM_LBUTTONDOWN: 
      { 
         // The user clicks the left button so the container scroll bar will scroll one step down 
         if(gImageViewer) 
         { 
            nRet = gImageViewer->GetFirstVisibleRow(&uRow, 0); 
            nRet = gImageViewer->SetFirstVisibleRow(uRow + 1, 0); 
         } 
      } 
      break; 
      case WM_RBUTTONDOWN: 
      { 
         // The user clicks the right button so the container scroll bar will scroll one step up. 
         if(gImageViewer) 
         { 
            nRet = gImageViewer->GetFirstVisibleRow(&uRow, 0); 
            nRet = gImageViewer->SetFirstVisibleRow(uRow - 1, 0); 
         } 
      } 
      break; 
   } 
   return TRUE; 
} 
// This function will create a container, add cells with image lists, and add some tags. 
// Then the function will add some actions to the container. 
L_INT LImageViewer_CreateExample(CWnd* pwndParent, LImageViewer& ImageViewer) 
{ 
   LBitmapList BitmapList; 
   DISPCONTAINERPROPERTIES DispContainerProp; 
   DISPCELLPROPERTIES      DispCellProp; 
   RECT                    rcRect; 
   L_INT                   nRet; 
   // Create a container equal in size to its parent window. 
   pwndParent->GetClientRect(&rcRect); 
   nRet = ImageViewer.Create(pwndParent->GetSafeHwnd(), &rcRect, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   gImageViewer = &ImageViewer; 
   // load a bitmap list. 
   nRet = BitmapList.Load(MAKE_IMAGE_PATH(TEXT("xa.dcm")), 0, ORDER_BGRORGRAY); 
   // if the image is corrupted or not found the program will destroy the container and terminate 
   if (nRet != SUCCESS) 
   { 
      ImageViewer.Destroy(0); 
      return nRet; 
   } 
   // Insert a new cell at the end of the container cell queue. 
   LImageViewerChild2 ImageViewerCell; 
   ImageViewerCell.Create(ImageViewer.GetWindowHandle(0), 0); 
   ImageViewerCell.EnableActionCallBack(TRUE) ; 
   ImageViewerCell.EnableTagCallBack(TRUE) ; 
   ImageViewer.InsertCell(ImageViewerCell.GetWindowHandle(0), -1, 0); 
   // Attach the loaded bitmaplist to the newly inserted cell. 
   nRet = ImageViewerCell.SetCellBitmapList(BitmapList.GetHandle(),TRUE,0); 
   if(nRet != SUCCESS) 
      return nRet; 
   // Add some tags to the cell 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 1"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(1, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 2"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 3"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(3, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 4"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("L"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image1 Text 5"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Top"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Bottom"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image1 Text 6"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(8, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_FRAME, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell.SetCellTag(0, DISPWIN_ALIGN_BOTTOMRIGHT , DISPWIN_TYPE_OWNERDRAW, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   BitmapList.SetHandle(NULL,NULL,FALSE); 
   // load another bitmap list 
   nRet = BitmapList.Load(MAKE_IMAGE_PATH(TEXT("mr.dcm")), 0, ORDER_BGRORGRAY); 
   if(nRet != SUCCESS) 
      return nRet; 
   // insert a new cell at the end of the container queue. 
   LImageViewerChild2 ImageViewerCell2; 
   ImageViewerCell2.Create(ImageViewer.GetWindowHandle(0), 0); 
   ImageViewerCell2.EnableActionCallBack(TRUE) ; 
   ImageViewerCell2.EnableTagCallBack(TRUE) ; 
   ImageViewer.InsertCell(ImageViewerCell2.GetWindowHandle(0), -1, 0); 
   // Attach the loaded bitmap list to the newly inserted cell. 
   nRet = ImageViewerCell2.SetCellBitmapList(BitmapList.GetHandle(),TRUE,0); 
   if(nRet != SUCCESS) 
      return nRet; 
   // Add some tags to the cell 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 1"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 2"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(4, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 3"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(6, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 4"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("Image3 Text 5"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image3 Text 6"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Image3 Text 7"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Image3 Text 8"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image3 Text 9"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(7, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_SCALE, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetCellTag(0, DISPWIN_ALIGN_BOTTOMRIGHT, DISPWIN_TYPE_OWNERDRAW, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   // Change the number of rows and columns to show all the inserted cells. 
   DispContainerProp.uStructSize = sizeof(DISPCONTAINERPROPERTIES); 
   DispContainerProp.uNumCols = 2; 
   DispContainerProp.uNumRows = 1; 
   DispContainerProp.uMask = DCPF_NUMROWS | DCPF_NUMCOLS; 
   nRet = ImageViewer.SetProperties(&DispContainerProp, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   // Change the number of sub-rows and sub-columns. 
   ZeroMemory(&DispCellProp, sizeof(DispCellProp)); 
   DispCellProp.uStructSize = sizeof(DISPCELLPROPERTIES); 
   DispCellProp.uNumCols = 3; 
   DispCellProp.uNumRows = 3; 
   nRet = ImageViewerCell2.SetCellProperties(&DispCellProp, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   BitmapList.SetHandle(NULL,NULL,FALSE); 
   // Add some actions to the container. 
   nRet = ImageViewerCell2.AddAction(110, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetAction(110, CONTAINER_MOUSE_BUTTON_LEFT,  DCACTION_ACTIVEONLY); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell2.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY); 
   if(nRet != SUCCESS) 
      return nRet; 
   ImageViewerCell.EnableActionCallBack(FALSE) ; 
   ImageViewerCell.EnableTagCallBack(FALSE) ; 
   ImageViewerCell.Destroy(0); 
   ImageViewerCell2.EnableActionCallBack(FALSE) ; 
   ImageViewerCell2.EnableTagCallBack(FALSE) ; 
   ImageViewerCell2.Destroy(0); 
   ImageViewer.Destroy(0); 
   gImageViewer = NULL; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Medical Image Viewer C++ Class Library Help