procedure TMainForm.TreeClientDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;
그리고 onDragDrop 이벤트에서
procedure TMainForm.TreeClientDragDrop(Sender, Source: TObject; X,
Y: Integer);
var
tmpNode : TTreenode;
AttachMode: TNodeAttachMode;
HT: THitTests;
begin
if TreeClient.Selected = nil then Exit;
if TreeClient.Selected.Level = 0 then begin
MessageBox(Application.Handle, PChar('최상위 노드는 이동할 수 없습니다.'), PChar(App_Title), MB_OK+MB_ICONWARNING+MB_TOPMOST);
Exit;
end;
tmpNode := TreeClient.GetNodeAt(x,y);
if tmpNode <> nil then begin
if (tmpNode.ImageIndex <> 0) and (tmpNode.ImageIndex <> 1) and
(tmpNode.ImageIndex <> 2) then
Exit;
if (ParentImageIndex(tmpNode) = 1) and
(ParentImageIndex(TreeClient.Selected) = 0) then begin
if MessageBox(Application.Handle, PChar(FmtMessage('임시그룹으로 이동시 해당 그룹(사용자)를 더이상 모니터링 할 수 없습니다.%n이동하시겠습니까?')), PChar(App_Title), MB_YESNO+MB_ICONWARNING+MB_TOPMOST) = IDNO then
Exit;
end;
end
else
Exit;
HT := TreeClient.GetHitTestInfoAt(X, Y);
if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then
begin
if (htOnItem in HT) or (htOnIcon in HT) then
AttachMode := naAddChild
else if htNowhere in HT then
AttachMode := naAdd
else if htOnIndent in HT then
AttachMode := naInsert;
TreeClient.Selected.MoveTo(tmpNode, AttachMode);
end;
end;
TreeView의 OnDragOver 이벤트
procedure TMainForm.TreeClientDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;
그리고 onDragDrop 이벤트에서
procedure TMainForm.TreeClientDragDrop(Sender, Source: TObject; X,
Y: Integer);
var
tmpNode : TTreenode;
AttachMode: TNodeAttachMode;
HT: THitTests;
begin
if TreeClient.Selected = nil then Exit;
if TreeClient.Selected.Level = 0 then begin
MessageBox(Application.Handle, PChar('최상위 노드는 이동할 수 없습니다.'), PChar(App_Title), MB_OK+MB_ICONWARNING+MB_TOPMOST);
Exit;
end;
tmpNode := TreeClient.GetNodeAt(x,y);
if tmpNode <> nil then begin
if (tmpNode.ImageIndex <> 0) and (tmpNode.ImageIndex <> 1) and
(tmpNode.ImageIndex <> 2) then
Exit;
if (ParentImageIndex(tmpNode) = 1) and
(ParentImageIndex(TreeClient.Selected) = 0) then begin
if MessageBox(Application.Handle, PChar(FmtMessage('임시그룹으로 이동시 해당 그룹(사용자)를 더이상 모니터링 할 수 없습니다.%n이동하시겠습니까?')), PChar(App_Title), MB_YESNO+MB_ICONWARNING+MB_TOPMOST) = IDNO then
Exit;
end;
end
else
Exit;
HT := TreeClient.GetHitTestInfoAt(X, Y);
if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then
begin
if (htOnItem in HT) or (htOnIcon in HT) then
AttachMode := naAddChild
else if htNowhere in HT then
AttachMode := naAdd
else if htOnIndent in HT then
AttachMode := naInsert;
TreeClient.Selected.MoveTo(tmpNode, AttachMode);
end;
end;