PB动态建立菜单的步骤如下:
1.创建模版菜单(m_template)
2.a)、在模版菜单里创建动态添加菜单项的函数:
/*====================================
Funtion name:Of_addmemu
Description: 将模版菜单项添加给指定的菜单
Argument:menu am_menu (添加菜单) string as_text(创建菜单项的text) string as_tag(创建菜单项的tag)
Return Value : succeed 1
=====================================*/
lm_item m_template
integer li_itemcount
lm_item = create m_template
lm_item.text =as_text
lm_item.tag = as_tag
li_itemcount = upperbound(am_menu.item[])
li_itemcount = li_itemcount+1 a
m_menu.item[li_itemcount] = lm_item
return 1
b、在模版菜单中创建弹出菜单的函数
/*====================================
Funtion name:Of_popmemu
Description: 弹出指定的菜单
Argument:menu am_menu (弹出菜单)
integer ai_x(弹出菜单的x坐标)
integer ai_y(弹出菜单的y坐标)
Return Value : NONE
=====================================*/
am_memu.popmenu(ai_x,ai_y)
为了能够一次创建多个菜单项
定义函数f_dynamic_menuitem()
/*======================================
Funtion name: f_dynamic_menuitem
Arugment: string as_menuitem[](添加菜单项的名称)
integer ai_x(弹出菜单的x坐标 )
integer ai_y( 弹出菜单的y坐标)
===================================*/
integer li_itemcount,i
m_template lm_dynamic_menu
li_itemcount = upperbound(as_menu[])
for i = 1 to li_itemcount
lm_dynamic_menu.of_additem(lm_dynamic_menu,as_menu[i],string(i))
next
lm_dynamic_menu.of_popmenu(ai_x,ai_y)
destory(lm_dynamic_menu)