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

#include <vcl.h>
#pragma hdrstop

#include "TTreeNodesDelete.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TTreeNodesDelete
// Property: ComCtrls.TCustomTreeView.Items
// Method: ComCtrls.TTreeNodes.Delete

// BeginCode
/*
The following example deletes an item in the tree view when
the user clicks on it, and if the checkbox is checked. This example
requires a populated TreeView.
*/
void __fastcall TForm1::TVMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
  THitTests HT;
  if (CheckBox1->Checked && Sender->ClassNameIs("TTreeView"))
  {
    TTreeView *pTV = dynamic_cast<TTreeView *>(Sender);
    HT = pTV->GetHitTestInfoAt(X,Y);
    if (HT.Contains(htOnItem))
      pTV->Items->Delete(pTV->GetNodeAt(X,Y));
  }
}
// EndCode
// EndExample: TTreeNodesDelete
//---------------------------------------------------------------------------
