本文主要是介绍ShellListView切换PopMenu的具体操作方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
需要用到ShellListView的OnMouseDown事件,PopMenu中的OnPopup()事件。其中还有如何获得PopMenu出现的坐标
代码如下:
procedure TFormSystemTree.lvMainMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);varp:Tpoint;
begin
if button=mbRight then
beginGetCursorPos(P);if lvMain.InnerListView.ItemIndex = -1 thenbeginlvMain.PopupMenu := PopupMenu2 ;
PopupMenu2.Popup(p.x,p.y);endelsebeginlvMain.PopupMenu := PopupMenu3;
PopupMenu3.Popup(p.x,p.y);end;
end;
end;
OnPopup()事件代码如下:
procedure TFormSystemTree.PopupMenu2Popup(Sender: TObject);
begin
lvMain.PopupMenu := nil ;
end;procedure TFormSystemTree.PopupMenu3Popup(Sender: TObject);
begin
lvMain.PopupMenu :=nil ;
end;
这篇关于ShellListView切换PopMenu的具体操作方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!