各位大神,求助:http://wenku.baidu.com/view/2ec4354c852458fb770b5617.html 我是参考该网址的介绍文章做的一个动态菜单。里面有句话是‘创建一个菜单m_popup,定义菜单条m_main,其下有十五个菜单项’不太理解。如何定义菜单条m_main,比较费解。同时,求大神指点下怎么做个动态菜单。
拜谢~!
------解决方案--------------------
forward
global type m_popup from menu
end type
type m_main from menu within m_popup
end type
type m_item1 from menu within m_main
end type
type m_item2 from menu within m_main
end type
type m_item3 from menu within m_main
end type
type m_item4 from menu within m_main
end type
type m_main from menu within m_popup
m_item1 m_item1
m_item2 m_item2
m_item3 m_item3
m_item4 m_item4
end type
global type m_popup from menu
m_main m_main
end type
end forward
global type m_popup from menu
m_main m_main
end type
global m_popup m_popup
type variables
Powerobject Anyobject
end variables
forward prototypes
public subroutine setmenuitem (string itemstring)
public subroutine popupmenu (integer x, integer y)
end prototypes
public subroutine setmenuitem (string itemstring);int itempos,itemorder=1,li
string currentitem
//
//messagebox("len(itemstring)",string(len(itemstring)))
if len(itemstring)=0 then
return
else
itempos=pos(itemstring,"
------解决方案--------------------
")
//messagebox("itempos",string(itempos))
DO WHILE itempos<>0 // itempos为间隔符"
------解决方案--------------------
"的位置
currentitem=left(itemstring,itempos -1) //取出子串
// messagebox("currentitem",string(currentitem))
itemstring=mid(itemstring,itempos+1)
this.m_main.item[itemorder].text=currentitem
itempos=pos(itemstring,"
------解决方案--------------------
")
//messagebox("itempos=pos(itemstring",string(itempos))
itemorder=itemorder+1
//messagebox("itemorder++",string(itemorder))
LOOP
this.m_main.item[itemorder].text=itemstring
for li=1 to itemorder
this.m_main.item[li].visible=true
this.m_main.item[li].enabled=true
next
end if
for li=itemorder+1 to 15
this.m_main.item[li].visible=false
next
//
//2)setitemdisable(integer itemorder) 返回值Null。
//该函数把第itemorder菜单项置灰(disable)。 脚本如下:
if itemorder<1 or itemorder>15 then
return
else
this.m_main.item[itemorder].enabled=false
end if
end subroutine
public subroutine popupmenu (integer x, integer y);this.m_main.popmenu(x,y)