PB关于右键动态菜单的问题
各位大神,求助: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)
end subroutine
on m_popup.create
m_popup=this
call super::create
this.text = "m_popup"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
this.m_main=create m_main
this.Item[UpperBound(this.Item)+1]=this.m_main
end on
on m_popup.destroy
call super::destroy
destroy(this.m_main)
end on
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
on m_main.create
call super::create
this.text = "m_main"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
this.m_item1=create m_item1
this.m_item2=create m_item2
this.m_item3=create m_item3
this.m_item4=create m_item4
this.Item[UpperBound(this.Item)+1]=this.m_item1
this.Item[UpperBound(this.Item)+1]=this.m_item2
this.Item[UpperBound(this.Item)+1]=this.m_item3
this.Item[UpperBound(this.Item)+1]=this.m_item4
end on
on m_main.destroy
call super::destroy
destroy(this.m_item1)
destroy(this.m_item2)
destroy(this.m_item3)
destroy(this.m_item4)
end on
type m_item1 from menu within m_main
end type
on m_item1.create
call super::create
this.text = "item1"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
end on
on m_item1.destroy
call super::destroy
end on
event clicked;Anyobject.triggerevent("ue_item1")
end event
type m_item2 from menu within m_main
end type
on m_item2.create
call super::create
this.text = "item2"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
end on
on m_item2.destroy
call super::destroy
end on
event clicked;Anyobject.triggerevent("ue_item2")
end event
type m_item3 from menu within m_main
end type
on m_item3.create
call super::create
this.text = "item3"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
end on
on m_item3.destroy
call super::destroy
end on
event clicked;Anyobject.triggerevent("ue_item3")
end event
type m_item4 from menu within m_main
end type
on m_item4.create
call super::create
this.text = "item4"
this.menutextcolor = 134217735
this.menubackcolor = 134217732
this.menuhighlightcolor = 134217741
this.textsize = 8
this.weight = 400
this.facename = "Tahoma"
this.titlebackcolor = 134217730
this.bitmapbackcolor = 12632256
this.menubitmaps = true
this.titlegradient = true
this.toolbartextcolor = 134217746
this.toolbarbackcolor = 67108864
this.toolbarhighlightcolor = 134217741
this.toolbargradient = true
this.bitmapgradient = true
end on
on m_item4.destroy
call super::destroy
end on
event clicked;Anyobject.triggerevent("ue_item4")
end event