")
itemorder++
LOOP
this.m_main.item[itemorder].text=itemstring
for i=1 to itemorder
this.m_main.item[i].visible=true
this.m_main.item[i].enabled=true
end if
for i=itemorder+1 to 15
this.m_main.item[i].visible=false
next
2)setitemdisable(integer itemorder) 返回值Null。
该函数把第itemorder菜单项置灰(disable)。
脚本如下:
if itemorder<1 or itemorder>15 then return
this.m_main.item[itemorder].enabled=false
3)popupmenu(integer x, integer y) 返回值Null。
该函数弹出菜单条m_main。
脚本如下:
this.m_main.popmenu(x,y)
二、 rbuttondown事件激发弹出菜单m_popup
---- 至此,我们就可以在窗口中任意对象如DataWindow、 Picture、 SingleLineEdit、 ListBox、 PictureListBox、 DropDownPictureListBox、 MultiLineEdit、 ListView、 TreeView等的rbuttondown事件中写脚本调用m_popup的函数来实现右键单击弹出一个菜单。下面以数据窗口dw_1为例,在其rbuttondown事件下写入脚本,使得右击dw_1 可弹出菜单:刷新/插入/删除/修改。步骤如下:
1、事先给窗口定义一个m_popup 型instance变量om_1:
m_popup om_1
2、dw_1的rbuttondown事件脚本:
if not isvalid(om_1) then
om_1= CREATE m_popup
end if
//把菜单的anyobject指向被右击的对象(dw_1)
om_1.anyobject=this
om_1.setmenuitem("刷新
关键词:用PB做一个通用右键菜单