L_DispContainerCreate

#include "ltivw.h"

L_LTIVW_API HDISPCONTAINER EXT_FUNCTION L_DispContainerCreate(hWndParent, lpRect, uFlags)

L_HWND hWndParent;

handle to the parent window

LPRECT lpRect;

pointer to a structure

L_UINT uFlags;

reserved for future

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 Flags that indicate the direction to which the calibration is applied. Possible values are:
  Value Meaning
  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 L_DispContainerHandlePalette. Slower, but allows demos to run on 8-bit monitors.

Returns

>0

A handle to the container.

NULL

An error occurred. To get extended error information, call GetLastError and 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 L_DispContainerSetProperties. To get the current characteristics of a specific container, call L_DispContainerGetProperties.

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 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 the existing splitters.

While the user is dragging the splitter using the left mouse button, an inverted line appears showing the new position.

If the user clicks the right mouse button while he is 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 L_DispContainerDestroy. For every call to L_DispContainerCreate, there must be a call to L_DispContainerDestroy.

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:

L_DispContainerGetWindowHandle, L_DispContainerDestroy, L_DispContainerSetProperties, L_DispContainerGetProperties, L_UseContainerControl, L_DispContainerGetHandle

Topics:

Using the Image Viewer

 

Image Viewer Functions: Using the Image Viewer

Example

This example will create a container, add cells with image lists and some tags. Then the function will add some actions to the container.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
/* This callback will be called every time the toolkit paints the first cell. */ 
L_INT EXT_CALLBACK TagCallBack1(HWND hCellWnd, 
L_INT    nCellIndex, 
HDC      hDC, 
RECT *   lpRect, 
L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   UNREFERENCED_PARAMETER(hCellWnd); 
   if (nCellIndex == 0) 
   { 
      // Draw an overlay text with italic font 
      static LOGFONT lf; 
      HFONT hFont, hOldFont; 
      lf.lfHeight = lpRect->bottom - lpRect->top ; 
      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 = SelectFont(hDC, hFont); 
      TextOut(hDC, lpRect->right, lpRect->bottom, TEXT("Owner Text"), 10); 
      SelectFont(hDC, hOldFont); 
      DeleteFont(hFont); 
   } 
   return TRUE; 
} 
HDISPCONTAINER DispContainerCreateExample(HWND hWndParent) 
{ 
   DISPCONTAINERPROPERTIES DispContainerProp; 
   DISPCELLPROPERTIES DispCellProp; 
   RECT rcRect; 
   L_INT nRet; 
   L_INT nCellIndex; 
   HDISPCONTAINER hCon; 
   HBITMAPLIST hBitmapList; 
   // Create a container at a size of the its parent. 
   GetClientRect(hWndParent, &rcRect); 
   hCon = L_DispContainerCreate (hWndParent, &rcRect, 0); 
   // Change the number of rows and cols to show all the inserted cells. 
   DispContainerProp.uStructSize = sizeof(DISPCONTAINERPROPERTIES); 
   DispContainerProp.uNumCols = 2; 
   DispContainerProp.uNumRows = 1; 
   DispContainerProp.uMask = DCPF_NUMROWS | DCPF_NUMCOLS; 
   nRet = L_DispContainerSetProperties (hCon, &DispContainerProp, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // load a bitmap list. 
   nRet = L_LoadBitmapList (MAKE_IMAGE_PATH(TEXT("Image2.cmp")), &hBitmapList, 0, ORDER_BGRORGRAY, NULL, NULL); 
   // if the image is corrupted, not found, or not supported, the program will destroy the container and terminate 
   if (nRet != SUCCESS) 
   { 
      MessageBox(hWndParent,TEXT("Could not load Image2.cmp"),TEXT("Error: Aborting"), MB_OK); 
      L_DispContainerDestroy (hCon, 0); 
      return NULL; 
   } 
   HWND hConWnd = L_DispContainerGetWindowHandle(hCon, 0); 
   HWND hCellWnd = L_DispContainerCreateCell(hConWnd, 0); 
   // Insert a new cell at the end of the container cell queue. 
   nCellIndex = L_DispContainerInsertCell(hCon, hCellWnd, -1, 0); 
   // Attach the loaded bitmaplist to the newly inserted cell. 
   nRet = L_DispContainerSetCellBitmapList(hCellWnd, 
   hBitmapList, 
   TRUE, 
   0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // Add some tags to the cell 
   L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 1"), 0); 
   nRet = L_DispContainerSetCellTag(hCellWnd, 1, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 2"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 3"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 3, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 4"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("L"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image1 Text 5"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Top"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Bottom"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image1 Text 6"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 8, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_FRAME, NULL, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_BOTTOMRIGHT , DISPWIN_TYPE_OWNERDRAW, NULL, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // Create a custom callback for the tag 
   nRet = L_DispContainerSetTagCallBack(hCellWnd, TagCallBack1, NULL); 
   if(nRet != SUCCESS) 
      return NULL; 
   // if the image is corrupted, not found, or not supported, the program will destroy the container and terminate 
   if (nRet != SUCCESS) 
   { 
      MessageBox(hWndParent,TEXT("Could not load Image3.dic"), TEXT("Error: Aborting"), MB_OK); 
      L_DispContainerDestroy (hCon, 0); 
      return NULL; 
   } 
   // load another bitmap list 
   nRet = L_LoadBitmapList (MAKE_IMAGE_PATH(TEXT("image1.cmp")), &hBitmapList, 0, ORDER_BGRORGRAY, NULL, NULL); 
   if(nRet != SUCCESS) 
      return NULL; 
   HWND hCellWnd1 = L_DispContainerCreateCell(hConWnd, 0); 
   // insert a new cell at the end of the container queue. 
   nCellIndex = L_DispContainerInsertCell (hCon, hCellWnd1, -1, 0); 
   // Attach the loaded bitmap list the newly inserted cell. 
   nRet = L_DispContainerSetCellBitmapList (hCellWnd1, 
   hBitmapList, 
   TRUE, 
   0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // Add some tags to the cell 
   nRet = L_DispContainerSetCellTag (hCellWnd1, 0, DISPWIN_ALIGN_TOPLEFT     , 0,TEXT("Image3 Text 1"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 2"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 4, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 3"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 6, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 4"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("Image3 Text 5"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image3 Text 6"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Image3 Text 7"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Image3 Text 8"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image3 Text 9"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 7, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_SCALE, NULL, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetCellTag(hCellWnd1, 1, DISPWIN_ALIGN_BOTTOMLEFT  , DISPWIN_TYPE_WLCENTERWIDTH, NULL, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // Change the number of sub-rows and sub-cols. 
   DispCellProp.uStructSize = sizeof(DISPCELLPROPERTIES); 
   DispCellProp.uNumCols = 3; 
   DispCellProp.uNumRows = 3; 
   DispCellProp.uMask = DCCELLPF_ROWS | DCCELLPF_COLS; 
   nRet = L_DispContainerSetCellProperties(hCellWnd, &DispCellProp, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   // Add some actions to the container. 
   nRet = L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_WINDOWLEVEL, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_OFFSET, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_SCALE, 0); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_WINDOWLEVEL, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSE_BUTTON_LEFT, DCACTION_ACTIVEONLY); 
   if(nRet != SUCCESS) 
      return NULL; 
   nRet = L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_SCALE, CONTAINER_MOUSE_BUTTON_MIDDLE, DCACTION_ACTIVEONLY); 
   if(nRet != SUCCESS) 
      return NULL; 
   return hCon; 
} 
// Destroy the container and the bitmap lists attached. 
L_VOID DestroyContainer(HDISPCONTAINER hCon) 
{ 
   if(hCon) 
      L_DispContainerDestroy (hCon, 0); 
} 

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