LImageViewerCell::BeginUpdate

Summary

Stops the viewer from being refreshed if any change is applied, it is generally useful to increase the control speed efficiency. To resume refreshing, use the LImageViewerCell::EndUpdate function.

Syntax

#include "ltwrappr.h"

L_INT LImageViewerCell::BeginUpdate(uFlags)

Parameters

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

Stops the viewer from refreshing after each change is applied, until refreshing is resumed by calling LImageViewerCell::EndUpdate. At that point the viewer will repaint to show all of the changes that have been made. This is useful for better visual results and for speed efficiency.

Required DLLs and Libraries

See Also

Functions

Topics

Example

This example creates a medical viewer control and two cells. then it will ask whether the apply some effects on the cell with or without using BeginUpdate/EndUpdate. Run this sample twice and see the difference

L_INT LImageViewer_BeginUpdateExample(CWnd* pParent, LImageViewer& ImageViewer, LBitmapList* pBitmapList) 
{ 
   DISPCONTAINERPROPERTIES DispContainerProp; 
   DISPCELLPROPERTIES DispCellProp; 
   RECT rcRect; 
   L_INT nRet; 
   L_INT nCellIndex; 
   L_UINT uScaleMode; 
 
   // Create a container at a size of the its parent. 
   pParent->GetClientRect(&rcRect);  
 
   nRet = ImageViewer.Create (pParent->GetSafeHwnd(), &rcRect, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
 
   // 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 = ImageViewer.SetProperties ( &DispContainerProp, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // load a bitmap list. 
   nRet = pBitmapList->Load(MAKE_IMAGE_PATH(TEXT("image1.dcm")), 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) 
   { 
      ImageViewer.Destroy (0); 
      return nRet; 
   } 
 
   LImageViewerCell * ImageViewerCell = new LImageViewerCell(); 
   ImageViewerCell->Create(ImageViewer.GetWindowHandle(0), 0); 
 
   // Insert a new cell at the end of the container cell queue. 
   nCellIndex = ImageViewer.InsertCell(ImageViewerCell->GetWindowHandle(0),  -1, 0); 
 
   // Attach the loaded bitmaplist to the newly inserted cell. 
   nRet = ImageViewerCell->SetCellBitmapList(pBitmapList->GetHandle(), 
                                        TRUE, 
                                        0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pBitmapList->SetHandle(NULL,NULL,FALSE);  
 
   // Add some tags to the cell 
   ImageViewerCell->SetCellTag(0, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 1"), 0); 
   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; 
 
   // if the image is corrupted, not found, or not supported, the program will destroy the container and terminate 
   if (nRet != SUCCESS) 
   { 
      ImageViewer.Destroy (0); 
      return nRet; 
   } 
 
   // load another bitmap list 
   nRet = pBitmapList->Load(MAKE_IMAGE_PATH(TEXT("Image2.dcm")), 0, ORDER_BGRORGRAY, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   ImageViewerCell = new LImageViewerCell(); 
   ImageViewerCell->Create(ImageViewer.GetWindowHandle(0), 0); 
 
   // insert a new cell at the end of the container queue. 
   ImageViewer.InsertCell (ImageViewerCell->GetWindowHandle(0), -1, 0); 
 
   // Attach the loaded bitmap list the newly inserted cell. 
   nRet = ImageViewerCell->SetCellBitmapList (pBitmapList->GetHandle(), 
                                         TRUE, 
                                         0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pBitmapList->SetHandle(NULL,NULL,FALSE);  
 
   // Add some tags to the cell 
   nRet = ImageViewerCell->SetCellTag (0, DISPWIN_ALIGN_TOPLEFT     , 0,TEXT("Image3 Text 1"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 2"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(4, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 3"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(6, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 4"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("Image3 Text 5"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image3 Text 6"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Image3 Text 7"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Image3 Text 8"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = ImageViewerCell->SetCellTag(0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image3 Text 9"), 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(7, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_SCALE, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetCellTag(1, DISPWIN_ALIGN_BOTTOMLEFT  , DISPWIN_TYPE_WLCENTERWIDTH, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetSubCellTag(8, 0, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 1"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetSubCellTag(0, 8, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 2"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetSubCellTag(1, 9, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 3"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetSubCellTag(2, 10, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 4"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = ImageViewerCell->SetSubCellTag(3, 11, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 5"), 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
 
   // Change the number of sub-rows and sub-cols. 
   DispCellProp.uStructSize = sizeof(DISPCELLPROPERTIES); 
   DispCellProp.uMask = DCCELLPF_ROWS | DCCELLPF_COLS | DCCELLPF_IMAGE_FIT; 
   DispCellProp.uNumCols = 3; 
   DispCellProp.uNumRows = 3; 
   DispCellProp.bIsFit = FALSE; 
 
   ImageViewerCell = ImageViewer.GetCellHandle(0, 0); 
   LImageViewerCell * ImageViewerCell1 = ImageViewer.GetCellHandle(1, 0); 
   nRet = ImageViewerCell->SetCellProperties(&DispCellProp, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pParent->ShowWindow(SW_MAXIMIZE); 
   pParent->UpdateWindow(); 
 
   L_INT nMessageRet = pParent->MessageBox(TEXT("This demo will do some effects on the Medical viewer, Do you want to use the begin and update?"), TEXT("Begin Update And End Update Demo"), MB_YESNO); 
 
   if (nMessageRet == IDYES) 
   { 
      ImageViewerCell->BeginUpdate( 0); 
      ImageViewerCell1->BeginUpdate(0); 
   } 
 
   DISPCELLTAGINFO TagInfo; 
   L_DOUBLE        dScale; 
   L_TCHAR szText[100] = TEXT("Edited Text 1"); 
   TagInfo.uStructSize = sizeof(DISPCELLTAGINFO); 
   TagInfo.uMask = DCTF_TEXT; 
   TagInfo.szText = szText; 
   ImageViewerCell->EditCellTag(0, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0); 
 
   nRet = ImageViewerCell->DeleteCellTag(8, DISPWIN_ALIGN_TOPLEFT, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Shift the second row, one row down 
   nRet = ImageViewerCell->GetCellTag(2, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   TagInfo.uPosition += 1; 
 
   nRet = ImageViewerCell->EditCellTag(2, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Shift the second row, one row down 
   nRet = ImageViewerCell1->GetSubCellTag(0, 8, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   TagInfo.szText = TEXT("Edited sub-cell Tag1"); 
   ImageViewerCell1->EditSubCellTag(0, 8, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0); 
 
   ImageViewerCell->DeleteSubCellTag(0, 8, DISPWIN_ALIGN_TOPLEFT, 0); 
 
   ImageViewerCell->AddAction( CONTAINER_ACTION_WINDOWLEVEL, 0); 
 
   ImageViewerCell->SetAction( CONTAINER_ACTION_WINDOWLEVEL, CONTAINER_MOUSE_BUTTON_LEFT, 0); 
   ImageViewerCell->AddAction( CONTAINER_ACTION_ALPHA, 0); 
   ImageViewerCell->AddAction( CONTAINER_ACTION_OFFSET , 0); 
   ImageViewerCell->AddAction( CONTAINER_ACTION_MAG, 0); 
   ImageViewerCell->AddAction( CONTAINER_ACTION_SCALE , 0); 
   ImageViewerCell->AddAction( CONTAINER_ACTION_STACK , 0); 
 
 
   DISPWLEVELACTIONPROPS DispContianerWindowLevel; 
   DispContianerWindowLevel.DispContainerActionProps.uStructSize = sizeof(DISPWLEVELACTIONPROPS); 
 
   ImageViewerCell->GetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CONTAINERLEVEL); 
   ImageViewerCell->GetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL); 
 
   DispContianerWindowLevel.nWidth = 20; 
   DispContianerWindowLevel.nCenter = 50; 
 
   ImageViewerCell->SetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, -1, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL); 
 
   ImageViewerCell1 = ImageViewer.GetCellHandle(1, 0); 
 
   ImageViewerCell1->SetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL); 
 
   ImageViewerCell->GetCellScale(0, &dScale, 0); 
 
   dScale *= 2; 
 
   ImageViewerCell->SetCellScale(-1, dScale, 0); 
 
   if (!ImageViewerCell->IsBitmapFlipped(0, 0)) 
      ImageViewerCell->FlipBitmap(-1, 0); 
 
   if (!ImageViewerCell->IsBitmapReversed(0, 0)) 
      ImageViewerCell->ReverseBitmap(-1, 0); 
 
   ImageViewerCell1->SetCellScale(0, dScale, 0); 
 
   ImageViewerCell->GetCellScaleMode(0, &uScaleMode, 0); 
 
   if (uScaleMode != CONTAINER_SCALEMODE_FIT) 
      uScaleMode = CONTAINER_SCALEMODE_FIT; 
   else 
      uScaleMode = CONTAINER_SCALEMODE_NORMAL; 
 
   ImageViewerCell1->SetCellScaleMode(-1, uScaleMode, 0); 
 
   ImageViewerCell->SetCellScaleMode(-1, uScaleMode, 0); 
 
   if (nMessageRet == IDYES) 
   { 
      ImageViewerCell->EndUpdate( 0); 
      ImageViewerCell->EndUpdate(0); 
   } 
 
   delete pBitmapList; 
 
   return SUCCESS; 
} 

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

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