LImageViewer::BeginUpdate

#include "ltwrappr.h"

L_INT LImageViewer::BeginUpdate(uFlags)

L_UINT uFlags;

/* reserved for future use */

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

Parameter

Description

uFlags

Reserved for future use. Pass 0.

Returns

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 LImageViewer::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

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::Create, LImageViewer::Destroy, LImageViewer::RepaintCell, LImageViewer::UpdateCellView, LImageViewer::EndUpdate

Topics:

Using the Image Viewer

 

Window Control/Image Viewer Functions: Using the Image Viewer

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 BitmapList)
{
   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 = BitmapList.Load(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\xa.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 ( FALSE, 0);
      return nRet;
   }
   // Insert a new cell at the end of the container cell queue.
   nCellIndex = ImageViewer.InsertCell( -1, 0);
   // Attach the loaded bitmaplist to the newly inserted cell.
   nRet = ImageViewer.SetCellBitmapList(nCellIndex,
                                        BitmapList.GetHandle(),
                                        TRUE,
                                        0);
   if(nRet != SUCCESS)
      return nRet;
   BitmapList.SetHandle(NULL,NULL,FALSE); 
   // Add some tags to the cell
   ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 1"), 0);
   nRet = ImageViewer.SetCellTag( nCellIndex, 1, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 2"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 3"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 3, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image1 Text 4"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("L"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image1 Text 5"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Top"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Bottom"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image1 Text 6"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 8, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_FRAME, NULL, 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 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 ( FALSE, 0);
      return nRet;
   }
   // load another bitmap list
   nRet = BitmapList.Load(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\image2.dic"), 0, ORDER_BGRORGRAY, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   // insert a new cell at the end of the container queue.
   nCellIndex = ImageViewer.InsertCell ( -1, 0);
   // Attach the loaded bitmap list the newly inserted cell.
   nRet = ImageViewer.SetCellBitmapList (nCellIndex,
                                         BitmapList.GetHandle(),
                                         TRUE,
                                         0);
   if(nRet != SUCCESS)
      return nRet;
   BitmapList.SetHandle(NULL,NULL,FALSE); 
   // Add some tags to the cell
   nRet = ImageViewer.SetCellTag ( nCellIndex, 0, DISPWIN_ALIGN_TOPLEFT     , 0,TEXT("Image3 Text 1"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 2, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 2"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 4, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 3"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 6, DISPWIN_ALIGN_TOPLEFT     , 0, TEXT("Image3 Text 4"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 1, DISPWIN_ALIGN_LEFTCENTER  , 0, TEXT("Image3 Text 5"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_BOTTOMLEFT  , 0, TEXT("Image3 Text 6"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_TOPCENTER   , 0, TEXT("Image3 Text 7"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_BOTTOMCENTER, 0, TEXT("Image3 Text 8"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_TOPRIGHT    , 0, TEXT("Image3 Text 9"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 0, DISPWIN_ALIGN_RIGHTCENTER , 0, TEXT("R"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 7, DISPWIN_ALIGN_TOPLEFT     , DISPWIN_TYPE_SCALE, NULL, 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetCellTag( nCellIndex, 1, DISPWIN_ALIGN_BOTTOMLEFT  , DISPWIN_TYPE_WLCENTERWIDTH, NULL, 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetSubCellTag( 0, 8, 0, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 1"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetSubCellTag( 1, 0, 8, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 2"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetSubCellTag( 1, 1, 9, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 3"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetSubCellTag( 1, 2, 10, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_USERDATA, TEXT("Sub Cell Tag 4"), 0);
   if(nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.SetSubCellTag( 1, 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;
   nRet = ImageViewer.SetCellProperties( 0, &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 update?"), TEXT("Begin Update And End Update Demo"), MB_YESNO);
   if (nMessageRet == IDYES)
      ImageViewer.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;
   ImageViewer.EditCellTag( 0, 0, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0);
   nRet = ImageViewer.DeleteCellTag( 0, 8, DISPWIN_ALIGN_TOPLEFT, 0);
   if(nRet != SUCCESS)
      return nRet;
   // Shift the second row, one row down
   nRet = ImageViewer.GetCellTag( 0, 2, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0);
   if(nRet != SUCCESS)
      return nRet;
   TagInfo.uPosition += 1;
   nRet = ImageViewer.EditCellTag( 0, 2, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0);
   if(nRet != SUCCESS)
      return nRet;
   // Shift the second row, one row down
   nRet = ImageViewer.GetSubCellTag( 1, 0, 8, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0);
   if(nRet != SUCCESS)
      return nRet;
   TagInfo.szText = TEXT("Edited sub-cell Tag1");
   ImageViewer.EditSubCellTag( 1, 0, 8, DISPWIN_ALIGN_TOPLEFT, &TagInfo, 0);
   ImageViewer.DeleteSubCellTag( 0, 0, 8, DISPWIN_ALIGN_TOPLEFT, 0);
   ImageViewer.AddAction( CONTAINER_ACTION_WINDOWLEVEL, 0);
   ImageViewer.SetAction( CONTAINER_ACTION_WINDOWLEVEL, CONTAINER_MOUSE_BUTTON_LEFT, 0);
   ImageViewer.AddAction( CONTAINER_ACTION_ALPHA, 0);
   ImageViewer.AddAction( CONTAINER_ACTION_OFFSET , 0);
   ImageViewer.AddAction( CONTAINER_ACTION_MAG, 0);
   ImageViewer.AddAction( CONTAINER_ACTION_SCALE , 0);
   ImageViewer.AddAction( CONTAINER_ACTION_STACK , 0);
   DISPWLEVELACTIONPROPS DispContianerWindowLevel;
   DispContianerWindowLevel.DispContainerActionProps.uStructSize = sizeof(DISPWLEVELACTIONPROPS);
   ImageViewer.GetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CONTAINERLEVEL);
   ImageViewer.GetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL);
   DispContianerWindowLevel.nWidth = 20;
   DispContianerWindowLevel.nCenter = 50;
   ImageViewer.SetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 0, -1, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL);
   ImageViewer.SetActionProperties( CONTAINER_ACTION_WINDOWLEVEL, 1, 0, &DispContianerWindowLevel, CONTAINER_ACTION_CELLLEVEL);
   ImageViewer.GetCellScale( 0, 0, &dScale, 0);
   dScale *= 2;
   ImageViewer.SetCellScale( 0, -1, dScale, 0);
   if (!ImageViewer.IsBitmapFlipped(0, 0, 0))
      ImageViewer.FlipBitmap(0, -1, 0);
   if (!ImageViewer.IsBitmapReversed(0, 0, 0))
      ImageViewer.ReverseBitmap(0, -1, 0);
   ImageViewer.SetCellScale( 1, 0, dScale, 0);
   ImageViewer.GetCellScaleMode( 0, 0, &uScaleMode, 0);
   if (uScaleMode != CONTAINER_SCALEMODE_FIT)
      uScaleMode = CONTAINER_SCALEMODE_FIT;
   else
      uScaleMode = CONTAINER_SCALEMODE_NORMAL;
   ImageViewer.SetCellScaleMode( 1, -1, uScaleMode, 0);
   ImageViewer.SetCellScaleMode( 0, -1, uScaleMode, 0);
   if (nMessageRet == IDYES)
      ImageViewer.EndUpdate( 0);
   return SUCCESS;
}