TDragOverEvent = procedure(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean) of object;property OnDragOver: TDragOverEvent;DescriptionUse an OnDragOver event to signal that the control can accept a dragged object so the user can drop or dock it.Within the OnDragOver event handler, change the Accept parameter to False to reject the dragged object. Leave Accept as True to allow the user to drop or dock the dragged object on the control.To change the shape of the cursor, indicating that the control can accept the dragged object, change the value of the DragCursor property for the control before the OnDragOver event occurs. The Source is the object being dragged, the Sender is the potential drop or dock site, and X and Y are screen coordinates in pixels. The State parameter specifies how the dragged object is moving over the control.Note: Within the OnDragOver event handler, the Accept parameter defaults to True. However, if an OnDragOver event handler is not supplied, the control rejects the dragged object, as if the Accept parameter were changed to False.property OnEndDrag: TEndDragEvent;DescriptionUse the OnEndDrag event handler to specify any special processing that occurs when dragging stops.
Used for OnEndDrag and OnEndDock event handlers.UnitControlstype TEndDragEvent = procedure(Sender, Target: TObject; X, Y: Integer) of object;DescriptionThe Sender is the object being dragged, Target is the object Sender is dragged to, and X and Y are screen coordinates in pixels.The OnEndDrag event is received by Sender. If the dragged object was dropped or docked and accepted by a control, the Target parameter of the OnEndDrag event is set to the object that accepted the sender. If the object was not dropped successfully, the value of Target is nil.
解决方案 »
- 研究!协议关联或注册问题!急!! 诚心求解!
- 大连理工大学2006秋季MBa招生严重不公!!!
- 不用ODBC和BDE如何连接SYSBASE数据库?
- Wise怎么支持长文件名
- 帮忙把VB代码翻译成DELPHI代码
- AnimateWindow (,,)后出来的窗口非活动状态???
- 请问如何用Delphi或C++Builder实现屏幕画面的截取?
- delphi的ActionToolBar控件的使用
- 怎样打印dbtext和dbedit的内容?
- 为什么我查询数据库总返回同一条记录?
- 一个quickrep的奇怪的问题,请进来看看
- 为什么BINDLAYER后自动生成的DATASET的VALUE是空(NULL)的?
State: TDragState; var Accept: Boolean);
var
TargetNode, SourceNode: TTreeNode;
begin
TargetNode := TreeView1.GetNodeAt (X, Y);
// accept dragging from itself
if (Source = Sender) and (TargetNode <> nil) then
begin
Accept := True;
// determines source and target
SourceNode := TreeView1.Selected;
// look up the target parent chain
while (TargetNode.Parent <> nil) and
(TargetNode <> SourceNode) do
TargetNode := TargetNode.Parent;
// if source is found
if TargetNode = SourceNode then
// do not allow dragging over a child
Accept := False;
end
else
Accept := False;
end;procedure CopyNodeUnder (TreeView: TTreeView;
SourceNode, TargetNode: TTreeNode);
var
NewNode: TTreeNode;
I: Integer;
begin
// add a new node
NewNode := TreeView.Items.AddChildFirst (TargetNode, '');
// copy the source
NewNode.Assign (SourceNode);
// recursively copy subitems
for I := SourceNode.Count - 1 downto 0 do
CopyNodeUnder (TreeView, SourceNode.Item [I], NewNode);
// delete source after copy (move)
TreeView.Items.Delete (SourceNode);
end;procedure TForm1.TreeView1DragDrop(Sender, Source: TObject;
X, Y: Integer);
var
TargetNode, SourceNode: TTreeNode;
begin
TargetNode := TreeView1.GetNodeAt (X, Y);
if TargetNode <> nil then
begin
SourceNode := TreeView1.Selected;
SourceNode.MoveTo (TargetNode, naAddChildFirst);
TargetNode.Expand (False);
TreeView1.Selected := TargetNode;
end;
end;
property OnDragDrop: TDragDropEvent;DescriptionUse the OnDragDrop event handler to specify what happens when the user drops an object. The Source parameter of the OnDragDrop event is the object being dropped, and the Sender is the control the object is being dropped on. The X and Y parameters are the coordinates of the mouse positioned over the control.procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);begin
Accept := Source is TLabel;end;This OnDragDrop event handler implements the drop behavior.procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);begin
if (Sender is TListBox) and (Source is TLabel) then
begin
with Sender as TListBox do
begin
Font := (Source as TLabel).Font;
Color := (Source as TLabel).Color;
end;
end;
end;