//---------------------------------------------------------------------------
//in
source...
void __fastcall
TForm1::TreeView1DragOver(TObject *Sender, TObject
*Source, int
X, int Y, TDragState State, bool &Accept)
{
//Check
to see if the Control being dragged is
//indeed a TreeView, and decide to accept the drop or not
if
(Source == Sender) Accept = true;
else
Accept = false;
//Scroll
if out of visibility
int
offset = TreeView1->Font->Height;
if
(Y >= TreeView1->Height + offset)
{
SendMessage(TreeView1->Handle, WM_VSCROLL, SB_LINEDOWN, 0);
}
if
(Y <= 0)
{
SendMessage(TreeView1->Handle, WM_VSCROLL, SB_LINEUP, 0);
}
}
//--------------------------------------------------------------------------------
void __fastcall TForm1::TreeView1MouseDown(TObject
*Sender, TMouseButton Button, TShiftState Shift, int X, int
Y)
{
if
(!dynamic_cast<TTreeView *>(Sender)) return;
//Convert
Sender into a TTreeView
TTreeView
*DragTreeView = (TTreeView *)Sender;
//Begin
the dragging process
DragTreeView->BeginDrag(0);
}
//--------------------------------------------------------------------------------
void __fastcall
TForm1::FormDragOver(TObject *Sender, TObject *Source,
int X, int
Y, TDragState State, bool &Accept)
{
Accept
= false;
//Scroll
if out of visibility
int
offset = TreeView1->Font->Height;
if
(Y >= TreeView1->Height + offset)
{
SendMessage(TreeView1->Handle, WM_VSCROLL, SB_LINEDOWN, 0);
}
if
(Y <= 0)
{
SendMessage(TreeView1->Handle, WM_VSCROLL, SB_LINEUP, 0);
}
}
|