怎样使一个控件有两个快捷菜单?(50分)

C

cansim

Unregistered / Unconfirmed
GUEST, unregistred user!
我想使用LISTVIEW控件,当右击其中空白的地方
的时候是一种菜单,当在其中内容上右击时又是一种菜单
具体怎么实现?[?]
还有LISTVIEW的双击事件,当在空白的双击时会出错
而在里面内容没这种问题,怎么解决?
谢谢![:)]
 
双机事件
if listview1.Selected<>nil then
begin
end;
 
在你的PopupMenu的OnPopup事件中判断当前是否选中了什么,然后决定要不要Popup,
以及要popup些什么
 
skywed你说的判断,是判断当前鼠标所选中的东西?
具体怎么判断,能不能写几行看看?
 
你试试看没有调试(看看TlistView.GetHitTestInfoAt的帮助):
listView 的 Mousedown事件中
var
p:TPoint;
begin
if button=mbRight then
begin
p:=ClientToScreen(Point((Sender AS TListView).Left+X),(Sender AS TListView).Top+y)));
if (htNoWhere in (Sender as Tlistview).GetHitTestInfoAt(X,Y)) then
popupmenu1.Popup(P.x,p.y)
else
popupmenu2.popup(p.x,p.y);
end;
end;
 
关键是看鼠标有没有选择中Item阿
手工控制一下吧
不要那么偷懒,嘻嘻

 
多人接受答案了。
 
顶部