试试下面的代码。
procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var dd:TTreeNode;
begin
if button= mbRight then
if treeView1.GetNodeAt(x,y)<>nil then
begin
ShowMessage('yyyyyyyyyyyy');
dd:=TreeView1.GetNodeAt(x,y);
TreeView1.Selected:=dd;
 end
else
ShowMessage('nnnnnnnnnnnn');end;

解决方案 »

  1.   

    指定popupmenu为你指定的popupmenu就好了,试试
      

  2.   

    在onmousedown事件下
     if Button = mbRight then
      begin
        l_Lparam := x + (y shl 16);//l_lPARAM :LPARAM;
        Sendmessage(tvwPersonList.Handle,WM_LBUTTONDOWN ,MK_LBUTTON,L_lparam);
        Sendmessage(tvwPersonList.Handle,WM_LBUTTONUP ,MK_LBUTTON,L_lparam);
    end;
    //这样当点击右键时,treeview也会认为是左键,不好的地方就是当你需要真正想要处理右键的时候会有麻烦,简单的办法可以通过加入标记来分辨。
      

  3.   

    也可以让getNodeAt的selected := true,如果要是处理菜单的情况还是用前面的