PB关于右键动态菜单的问题

liaicheng12 2013-05-24 03:40:13
各位大神,求助:http://wenku.baidu.com/view/2ec4354c852458fb770b5617.html 我是参考该网址的介绍文章做的一个动态菜单。里面有句话是‘创建一个菜单m_popup,定义菜单条m_main,其下有十五个菜单项’不太理解。如何定义菜单条m_main,比较费解。同时,求大神指点下怎么做个动态菜单。
拜谢~!
...全文
193 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
liaicheng12 2013-05-24
  • 打赏
  • 举报
回复
太感谢你了~!太用心了,致敬~!我研究研究再。
I_am_Z 2013-05-24
  • 打赏
  • 举报
回复
这个是我给你做好的menu的源文件,你在你的那个menu上点右键,编辑源,打开文本,将我的代码替换进去,保存,你自己看看吧!
I_am_Z 2013-05-24
  • 打赏
  • 举报
回复


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


I_am_Z 2013-05-24
  • 打赏
  • 举报
回复
弹出错误,说明你有的地方没有按人家说的做对。
liaicheng12 2013-05-24
  • 打赏
  • 举报
回复
引用 5 楼 Dersak 的回复:
给你做几部操作的截图 这要再不会,我就彻底被你打败了。
首先谢谢你这么用心~!这些我都实现了,我现在把那个连接的源代码复制过去后,也按照所说,创建了setmenuitem函数(注:该函数是在m_popmenu下面创建的),可是他提示‘Incompatible property m_main for type m_pop'错误。所以,问题在于我没有理解’创建一个菜单m_popup,定义菜单条m_main‘这句话吧。
I_am_Z 2013-05-24
  • 打赏
  • 举报
回复
给你做几部操作的截图




这要再不会,我就彻底被你打败了。
liaicheng12 2013-05-24
  • 打赏
  • 举报
回复
引用 3 楼 Dersak 的回复:
这个文档上讲的东西,你照着做就行了,没什么技术难度啊。莫非你不知道怎么操作?
呵呵,对他的所谓‘定义菜单条m_main’不是很清楚,,入门菜鸟。
I_am_Z 2013-05-24
  • 打赏
  • 举报
回复
这个文档上讲的东西,你照着做就行了,没什么技术难度啊。莫非你不知道怎么操作?
liaicheng12 2013-05-24
  • 打赏
  • 举报
回复
也太冷清了吧,顶一记~!
liaicheng12 2013-05-24
  • 打赏
  • 举报
回复
自己顶顶~!

1,072

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧