一般鼠标点击ListView会改变项的选中状态(不管是左键还是右键),
如何才能使得右键不改变选中状态?我只要弹出菜单。

解决方案 »

  1.   

    private
      ......
      OldWndMethod: TWndMethod;
      procedure NewWndMethod(var message:TMessage);
      ......
    public
      procedure AfterConstruction; override;implementation......procedure TFormContractList.AfterConstruction; (//FormContractList是我的FORM,不要照抄)
    begin
      inherited;
      OldWndMethod := ListView.WindowProc;
      ListView.WindowProc := NewWndMethod;
    end;procedure TFormContractList.NewWndMethod(var message: TMessage);
    begin
      case message.Msg of
      //WM_Paint: ListView.Columns[ListView.Columns.Count - 1].Width := -2;
      WM_RButtonDown, WM_RButtonUp: Exit;
      end;  OldWndMethod(message);
    end; 
      

  2.   

    去掉WM_RButtonUp就完美了,因为我还需要弹出菜单