代码
procedure TResTree.TreeView2MouseDown(Sender: TObject;
 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  p:TPOINT;
  Axis_X,Axis_Y:Integer;
  VL_Node:TTreeNode;
begin         
 if Button=mbRight then  ~~~这句话出现错误
     begin
           VL_Node:=TreeView2.GetNodeAt(X,Y);
           if (VL_Node<>nil) and  (VL_Node.Selected) then
           begin
                 GetCursorPos(p);
                 Axis_X := p.X;
                 Axis_Y := p.Y;
                 PopupMenu1.Popup(Axis_X,Axis_Y);
           end;
     end;
end;  

解决方案 »

  1.   

    在activeform中不行~~~,在普通窗体中没问题。
      

  2.   

    在ActiveForm中是可以响应鼠标事件的,鼠标事件是定义在Use 中的*_TLB单元中的。
    原先Delphi自动生成的是这样的
    interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ActiveX, AxCtrls, ActiveFormProj1_TLB, StdVcl, ExtCtrls, StdCtrls;
    改成这样就行了!interfaceuses
      ActiveFormProj1_TLB, Windows, Messages, SysUtils, Classes, Graphics, Controls,
      Forms, Dialogs, ActiveX, AxCtrls, StdVcl, ExtCtrls, StdCtrls;