L_DispContainerHandlePalette

#include "l_bitmap.h"

L_LTIVW_API L_BOOL EXT_FUNCTION L_DispContainerHandlePalette(hCellWnd, uMessage, wParam, uFlags)

Provides an interface with the viewer to allow it to receive messages that inform the control that the palette has been changed.

Parameters

L_HWND hCellWnd

Handle to the cell window.

L_UINT uMessage

Value that indicate the message that will be sent to the viewer main window.

WPARAM wParam

wParam value to be passed to the message.

L_UINT uFlags

Reserved for future use. Pass 0.

Returns

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

Comments

This function is used to display images correctly when working on 8-bit viewing systems.

The allowed messages to be recived through the parameter uMessage are:

In order to use this function, first set the uFlags parameter of the L_DispContainerCreate function to CONTAINER_HANDLEPALETTE.

Required DLLs and Libraries

Platforms

The toolkit comes in Win32 and x64 editions that can support development of software applications for any of the following environments:

Windows 10

Windows 8

Windows 7

Windows Vista

Windows XP

Windows 2000

See Also

Functions

Topics

Example

This example creates a medical viewer control that works on 8-bit palette display monitors.

typedef struct tagDATA 
{ 
   HBITMAPLIST      hBitmapList; 
   L_BOOL           bWindowLevel; 
   L_INT            nAction; 
   HDISPCONTAINER   hCon; 
   L_INT            nApplyToAllSubCells; 
   HWND             hWndAnimationDialog; 
} 
DATA, * LPDATA; 
 
HWND hWndParent; 
#define SETDATA(hwnd, h) L_SETWINDOWLONGPTR(hwnd, GWLP_USERDATA, (HANDLE)(h)) 
#define LOCKDATA(hwnd) ((LPDATA) GlobalLock((HANDLE)L_GETWINDOWLONGPTR(hwnd, GWLP_USERDATA))) 
#define UNLOCKDATA(hwnd) GlobalUnlock((HANDLE)L_GETWINDOWLONGPTR(hwnd, GWLP_USERDATA)) 
 
L_INT CreateNewCell(HWND hWnd, L_TCHAR * szText) 
{ 
   L_INT nRet, nIndex; 
   LPDATA pData = (LPDATA)LOCKDATA(hWnd); 
 
   nRet = L_LoadBitmapList(szText, &pData->hBitmapList, 0, ORDER_BGRORGRAY, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   HWND hConWnd = L_DispContainerGetWindowHandle(pData->hCon, 0); 
   HWND hCellWnd = L_DispContainerCreateCell(hConWnd, 0); 
 
   nIndex = L_DispContainerInsertCell(pData->hCon, hCellWnd, -1, 0); 
 
   nRet = L_DispContainerSetCellBitmapList(hCellWnd, 
                                           pData->hBitmapList, 
                                           TRUE, 
                                           0); 
 
   return SUCCESS; 
} 
 
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) 
{ 
   LPDATA pData = NULL; 
   pData = (LPDATA)LOCKDATA(hWnd); 
 
   L_INT nCellIndex = 0; 
   HWND hCellWnd = NULL; 
   hCellWnd = L_DispContainerGetCellWindowHandle(pData->hCon, nCellIndex, 0); 
 
   switch(uMessage) 
   { 
   case WM_SYSCOLORCHANGE: 
   case WM_QUERYNEWPALETTE: 
      if (hCellWnd != NULL) 
      { 
         L_DispContainerHandlePalette(hCellWnd, uMessage, 0, 0); 
         L_DispContainerRepaintCell(hCellWnd, 0); 
      } 
      break; 
 
   case WM_PALETTEISCHANGING: 
   case WM_PALETTECHANGED: 
      if (hCellWnd != NULL) 
      { 
         L_DispContainerHandlePalette(hCellWnd, uMessage, wParam, 0); 
         L_DispContainerRepaintCell(hCellWnd, 0); 
      } 
      break; 
   } 
   return DefWindowProc(hWnd, uMessage, wParam, lParam); 
} 
 
L_INT DispContainerHandlePaletteExample(HINSTANCE hInstance) 
{ 
   MSG                     uMessage; 
   WNDCLASS                wndclass; 
   HANDLE                  hMem; 
   LPDATA                  pData; 
   HACCEL                  hAccel; 
   RECT                    rcRect; 
   DISPCONTAINERPROPERTIES DispContainerProp; 
   DISPCELLPROPERTIES      DispCellProp; 
   L_TCHAR                 szText[L_MAXPATH]; 
   L_INT                   nRet; 
 
   //register the Image child window class 
   wndclass.style         = CS_HREDRAW | CS_VREDRAW; 
   wndclass.lpfnWndProc   = WndProc; 
   wndclass.cbClsExtra    = 0; 
   wndclass.cbWndExtra    = sizeof(HANDLE); 
   wndclass.hInstance     = hInstance; 
   wndclass.hIcon         = NULL; 
   wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW); 
   wndclass.hbrBackground = GetStockBrush(GRAY_BRUSH); 
   wndclass.lpszMenuName  = NULL; 
   wndclass.lpszClassName = TEXT("HandlePaletteExample"); 
 
   if (!RegisterClass(&wndclass)) 
      return 0; 
 
   hWndParent = CreateWindowEx(WS_EX_CLIENTEDGE, 
                               TEXT("HandlePaletteExample"), 
                               TEXT("Image Viewer Demo"), 
                               WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 
                               CW_USEDEFAULT, 
                               CW_USEDEFAULT, 
                               CW_USEDEFAULT, 
                               CW_USEDEFAULT, 
                               NULL, 
                               NULL, 
                               hInstance, 
                               NULL); 
 
   hMem = GlobalAlloc (GHND, sizeof (DATA)); 
   SETDATA (hWndParent, hMem);  
   if(!hMem) 
      return(FALSE); 
 
   pData = (LPDATA)LOCKDATA(hWndParent); 
   memset(pData, 0, sizeof(LPDATA)); 
   pData->hCon = NULL; 
 
   // you must unlock the medical suite in order to be able to use the medical viewer. 
   //UNLOCKSUPPORT(); 
 
   // Initialize the container by making it the same size as its parent. 
   GetClientRect(hWndParent, &rcRect); 
   pData->hCon = L_DispContainerCreate(hWndParent, &rcRect, CONTAINER_HANDLEPALETTE); 
 
   // If there is a problem occur while  
   if (pData->hCon == NULL) 
   { 
      L_INT nError = GetLastError(); 
      wsprintf(szText, TEXT("Error %d"), nError); 
      MessageBox(hWndParent, szText, TEXT("Aborting"), MB_OK); 
 
      L_DispContainerDestroy(pData->hCon, 0); 
      GlobalFree(hMem); 
      return FALSE; 
   } 
 
   HWND hCellWnd = L_DispContainerGetCellWindowHandle(pData->hCon, 0, 0); 
 
   // Add some action and activate them  
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_WINDOWLEVEL, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ALPHA, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_OFFSET , 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_MAG, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_SCALE , 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_STACK , 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_RULER, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_ELLIPSE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_RECTANGLE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_TEXT, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_ARROW, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_ANGLE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_ANNOTATION_HILITE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_RECTANGLE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_NUDGETOOL, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_SHRINKTOOL, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_ELLIPSE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_POLYGON, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_FREEHAND, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_MAGICWAND, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_COLORRANGE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_CIRCLE, 0); 
   L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_REGION_SQUARE, 0); 
 
   // assign the action to a mouse button. 
   L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_WINDOWLEVEL, CONTAINER_MOUSE_BUTTON_LEFT, 0); 
   L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSE_BUTTON_RIGHT, 0); 
   L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_SCALE, CONTAINER_MOUSE_BUTTON_MIDDLE, 0); 
   L_DispContainerSetAction(hCellWnd, CONTAINER_ACTION_STACK, CONTAINER_MOUSE_WHEEL, 0); 
 
   SetCursor(LoadCursor(NULL, IDC_WAIT)); 
 
   // set the image viewer interface to show two cells, that are arranged horizontaly 
   DispContainerProp.uStructSize = sizeof(DISPCONTAINERPROPERTIES); 
   DispContainerProp.uNumCols = 2; 
   DispContainerProp.uNumRows = 1; 
   DispContainerProp.uMask = DCPF_NUMROWS | DCPF_NUMCOLS; 
 
   nRet = L_DispContainerSetProperties(pData->hCon, &DispContainerProp, 0); 
 
   CreateNewCell(hWndParent, MAKE_IMAGE_PATH(TEXT("xa.dcm"))); 
 
   // Set some tags. 
   L_DispContainerSetCellTag(hCellWnd, 2, DISPWIN_ALIGN_TOPLEFT,    DISPWIN_TYPE_USERDATA,      TEXT("EX. ID 230-36-5448"), 0); 
   L_DispContainerSetCellTag(hCellWnd, 4, DISPWIN_ALIGN_TOPLEFT,    DISPWIN_TYPE_FRAME,         NULL,0); 
   L_DispContainerSetCellTag(hCellWnd, 6, DISPWIN_ALIGN_TOPLEFT,    DISPWIN_TYPE_SCALE,         NULL,0); 
   L_DispContainerSetCellTag(hCellWnd, 2, DISPWIN_ALIGN_BOTTOMLEFT, DISPWIN_TYPE_WLCENTERWIDTH, NULL,0); 
   L_DispContainerSetCellTag(hCellWnd, 1, DISPWIN_ALIGN_BOTTOMLEFT, DISPWIN_TYPE_FIELDOFVIEW,   NULL,0); 
   L_DispContainerSetCellTag(hCellWnd, 1, DISPWIN_ALIGN_TOPRIGHT,   DISPWIN_TYPE_USERDATA,      TEXT("Good, Guy"), 0); 
   L_DispContainerSetCellTag(hCellWnd, 2, DISPWIN_ALIGN_TOPRIGHT,   DISPWIN_TYPE_USERDATA,      TEXT("PID 125-98-445"), 0); 
   L_DispContainerSetCellTag(hCellWnd, 3, DISPWIN_ALIGN_TOPRIGHT,   DISPWIN_TYPE_USERDATA,      TEXT("DOB 08/02/1929"), 0); 
   L_DispContainerSetCellTag(hCellWnd, 5, DISPWIN_ALIGN_TOPRIGHT,   DISPWIN_TYPE_USERDATA,      TEXT("03/16/1999"), 0); 
   L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_BOTTOMLEFT, DISPWIN_TYPE_RULERUNIT,      NULL,  0); 
 
   DispCellProp.uStructSize = sizeof(DISPCELLPROPERTIES); 
   DispCellProp.bIsFit = TRUE; 
   DispCellProp.uMask = DCCELLPF_IMAGE_FIT; 
 
   nRet = L_DispContainerSetCellProperties(hCellWnd, &DispCellProp, 0); 
 
   CreateNewCell(hWndParent, MAKE_IMAGE_PATH(TEXT("mr.dcm"))); 
 
 
   HWND hCellWnd1 = L_DispContainerGetCellWindowHandle(pData->hCon, 1, 0); 
 
   // set some tags 
   L_DispContainerSetCellTag(hCellWnd1, 1, DISPWIN_ALIGN_TOPLEFT,       DISPWIN_TYPE_USERDATA,      TEXT("MRI"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 2, DISPWIN_ALIGN_TOPLEFT,       DISPWIN_TYPE_USERDATA,      TEXT("EX. ID G-1194-24"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 4, DISPWIN_ALIGN_TOPLEFT,       DISPWIN_TYPE_FRAME,         NULL,0); 
   L_DispContainerSetCellTag(hCellWnd1, 6, DISPWIN_ALIGN_TOPLEFT,       DISPWIN_TYPE_SCALE,         NULL,0); 
   L_DispContainerSetCellTag(hCellWnd1, 2, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_WLCENTERWIDTH, NULL,0); 
   L_DispContainerSetCellTag(hCellWnd1, 1, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_FIELDOFVIEW,   NULL,0); 
   L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_USERDATA,      TEXT("THK 10 mm"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 3, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_USERDATA,      TEXT("TR 1333.33"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 4, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_USERDATA,      TEXT("TE 11.98"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 6, DISPWIN_ALIGN_BOTTOMLEFT,    DISPWIN_TYPE_USERDATA,      TEXT("Comm longaxis - Normal"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 0, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("Community Hospital"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 1, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("Nice, Fellow"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 2, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("PID 123-45-6789"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 3, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("DOB 05/13/1936"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 4, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("Sex M"), 0); 
   L_DispContainerSetCellTag(hCellWnd1, 5, DISPWIN_ALIGN_TOPRIGHT,      DISPWIN_TYPE_USERDATA,      TEXT("06/26/1995"), 0); 
 
   // set the cell interface so it shows 4 frames at once. 
   DispCellProp.uNumCols = 2; 
   DispCellProp.uNumRows = 2; 
   DispCellProp.bIsFit = TRUE; 
   DispCellProp.bOnMove = TRUE; 
   DispCellProp.uMask = DCCELLPF_COLS | DCCELLPF_ROWS | DCCELLPF_IMAGE_FIT | DCCELLPF_APPLYONMOVE; 
 
   nRet = L_DispContainerSetCellProperties(hCellWnd1, &DispCellProp, 0); 
 
 
   SetCursor(LoadCursor(NULL, IDC_ARROW)); 
 
   ShowWindow(hWndParent, SW_MAXIMIZE); 
   UpdateWindow(hWndParent); 
 
   hAccel = LoadAccelerators(hInstance, TEXT("HandlePaletteExample")); 
 
   while (GetMessage (&uMessage, NULL, 0, 0)) 
   { 
      if(!TranslateMDISysAccel (hWndParent, &uMessage) && 
         !TranslateAccelerator (hWndParent, hAccel, &uMessage)) 
      { 
         TranslateMessage (&uMessage); 
         DispatchMessage (&uMessage); 
      } 
   } 
 
   GlobalFree(hMem); 
   return (L_INT)uMessage.wParam; 
} 

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

LEADTOOLS Medical Image Viewer C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.