您的位置:首页 > 其它

有关右键菜单添加菜单项的操作

2010-06-08 20:06 344 查看
var
//m:tmenuitem ;//使用变量只能添加一个菜单项
p: tpoint ;
begin
self.PopupMenu1.Items.Clear;

//添加子菜单
self.PopupMenu1.Items.Add(tMenuItem.Create(self));
self.PopupMenu1.Items[self.PopupMenu1.Items.Count-1].Caption := '123' ;
self.PopupMenu1.Items[self.PopupMenu1.Items.Count-1].OnClick := amenuclick ; //aMenuClick是一个预先定义好的菜单动作事件。

self.PopupMenu1.Items.Add(tMenuItem.Create(self));
self.PopupMenu1.Items[self.PopupMenu1.Items.Count-1].Caption := '456' ;
self.PopupMenu1.Items[self.PopupMenu1.Items.Count-1].OnClick := amenuclick ;

//定义显示的位置

p.x := self.SpeedButton8.Left ;
p.y := self.SpeedButton8.Top + self.SpeedButton8.Height -1 ;
P:=self.SpeedButton8.Parent.ClientToScreen(p) ;

//显示菜单

self.PopupMenu1.Popup(p.X,p.Y);

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐