Board index » delphi » GetNodeAt Bug?

GetNodeAt Bug?

Why will the following not work in Delphi6?
Only after a few rights clicks will it select the node!

procedure TForm1.TreeView1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

var
    TreeNode: TTreeNode;
Begin
    if button = mbRight then
     begin
       TreeNode := Treeview1.GetNodeAt(x, y);
          if TreeNode <> nil then
              TreeView1.Selected := TreeNode;
      end;
end;

 

Re:GetNodeAt Bug?


Try the next:

if (Button = mbRight) then
begin
  TreeNode := Treeview1.GetNodeAt(x, y);
  if Assigned(TreeNode) then
    TreeNode.Selected := True;
end

--
With best regards, Mike Shkolnik
E-Mail: mshkol...@scalabium.com
WEB: http://www.scalabium.com

Abe Buchinger <abe.b...@worldnet.att.net> D???
???Y??:3cfd1424$1_2@dnews...

Quote
> Why will the following not work in Delphi6?
> Only after a few rights clicks will it select the node!

> procedure TForm1.TreeView1MouseUp(Sender: TObject; Button: TMouseButton;
>   Shift: TShiftState; X, Y: Integer);

> var
>     TreeNode: TTreeNode;
> Begin
>     if button = mbRight then
>      begin
>        TreeNode := Treeview1.GetNodeAt(x, y);
>           if TreeNode <> nil then
>               TreeView1.Selected := TreeNode;
>       end;
> end;

Other Threads