//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "BeginUpdate.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: BeginUpdate
// Method: Classes.TCollection.BeginUpdate
// Method: Classes.TCollection.EndUpdate
// Method: ComCtrls.TStatusPanels.Add
// Property: Classes.TCollection.Count
// Property: ComCtrls.TStatusPanels.Items

// BeginCode
/*
The following example adds a panel to the status bar control
when the user clicks the button and adds a caption to the 
panel. The code uses BeginUpdate and EndUpdate to prevent 
repaints until the operation is complete.  A try...finally 
block ensures EndUpdate is called even when an exception 
occurs.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int PanelIndex;

  StatusBar1->Panels->BeginUpdate();
  PanelIndex = StatusBar1->Panels->Count - 1;
  try
  {
    StatusBar1->Panels->Add();
    PanelIndex++;
    StatusBar1->Panels->Items[PanelIndex]->Text = "Panel" + IntToStr(PanelIndex);
  }
  __finally
  {
    StatusBar1->Panels->EndUpdate();
  }
}
// EndCode
// EndExample: BeginUpdate
//---------------------------------------------------------------------------
