PB菜单问题,能不能动态创建菜单

hemhem 2006-11-02 03:44:16
意思如下:
在数据库中定义菜单结构,

ID 菜单名称 上级菜单ID 打开窗口的名称 参数
1 系统维护 NULL NULL NULL
2 商品资料增加 1 w_Goods_Add NULL
3 商品资料修改 1 w_Goods_Modifly NULL

以类似这么一个形式提供菜单结构,
PB中事先新建一个菜单,可能只包括 窗口和帮助 2个菜单项
想在程序中可以在窗口菜单项前插入数据库结构中的菜单项,并定义每个项的CLICKED事件

以前我看到过一个动态创建菜单的例子,他在一个菜单项下动态加了几十个子菜单,如果那样能实现的话按我上面说的也可以实现,如果谁有这个例子能不能发个给我过提供一下下载的地址。
...全文
641 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
rightyeah 2006-11-10
  • 打赏
  • 举报
回复
pb6可以在窗口菜单上动态添加菜单项的,pb10不行,其他的环境没有试过。用动态添加菜单项的办法,可以无限制地增加子菜单,而且也可以根据数据而改变。
另一种做法就比较笨了,就是增加若干菜单项,然后隐藏起来,等需要用的时候再显示。
第三种做法就是不要用窗口菜单,改用弹出菜单,可以完全用数据定制菜单的。http://community.csdn.net/Expert/topic/5007/5007436.xml?temp=.7694513
最后的办法就是:用api自己改吧
hemhem 2006-11-04
  • 打赏
  • 举报
回复
谢谢大家,我做动态菜单的目的主要是想允许用户自己添加查询,查询窗口也可以自己挂到菜单上,如果我做好了跟大家分享代码
  • 打赏
  • 举报
回复
动态菜单可以实现的,把菜单名存在数据库里
li_d_s 2006-11-03
  • 打赏
  • 举报
回复
发了个例子给你,看看
changwu 2006-11-03
  • 打赏
  • 举报
回复
我也想知道具体是怎么实现动态从数据库表中取菜单名的。
帮忙发下给我vchang98@163.com
balloonman2002 2006-11-02
  • 打赏
  • 举报
回复
http://blog.csdn.net/balloonman2002/archive/2004/06/28/28708.aspx
zym_xf2003117 2006-11-02
  • 打赏
  • 举报
回复
不好意思,没找到源码,我记得好象是
先创建一个menu_test,然后定义menu_test test,然后create menu_test赋给窗口菜单的ID,不知道行不行,你自己试一下吧
还有一个方法是用API函数,要好几个GetMenu();AppendMenu(),就是挺麻烦的。
da21 2006-11-02
  • 打赏
  • 举报
回复
关注
tdtxflsh 2006-11-02
  • 打赏
  • 举报
回复
为什么要用动态菜单呀,把所有你想要菜单全部都加上,然后想要的就显示出来,不想用的就引藏不就行了吗。
zym_xf2003117 2006-11-02
  • 打赏
  • 举报
回复
可以的,以前做过,找到了代码再发给你
不过PB里面对动态菜单、动态数据窗口等的运用好象有一些问题,就是在PB环境下运行都没问题但生成可执行文件后运行就有问题了,一直没搞清楚,大概是我没找到关键所在,有没有高手出来关于这个问题指点一下~
lovelihp 2006-11-02
  • 打赏
  • 举报
回复
希望看到代码
青锋-SS 2006-11-02
  • 打赏
  • 举报
回复
应该能
hemhem 2006-11-02
  • 打赏
  • 举报
回复
我的邮件地址:xhemhem@163.com
pb动态创建树和菜单 forward global type w_tv from window end type type cb_2 from commandbutton within w_tv end type type cb_1 from commandbutton within w_tv end type type sle_1 from singlelineedit within w_tv end type type st_1 from statictext within w_tv end type end forward global type w_tv from window integer width = 1381 integer height = 620 boolean titlebar = true string title = "Untitled" boolean controlmenu = true windowtype windowtype = response! long backcolor = 67108864 string icon = "AppIcon!" boolean center = true cb_2 cb_2 cb_1 cb_1 sle_1 sle_1 st_1 st_1 end type global w_tv w_tv on w_tv.create this.cb_2=create cb_2 this.cb_1=create cb_1 this.sle_1=create sle_1 this.st_1=create st_1 this.Control[]={this.cb_2,& this.cb_1,& this.sle_1,& this.st_1} end on on w_tv.destroy destroy(this.cb_2) destroy(this.cb_1) destroy(this.sle_1) destroy(this.st_1) end on event open;String ls_Parm, ls_temp, ls_Name, ls_title ls_Parm = Trim( Message.StringParm ) ls_temp = Right( ls_Parm, 1 ) ls_Name = Left( ls_Parm, Lenw( ls_Parm ) - 2 ) IF ls_temp = 'T' THEN ls_title = '添加 ' + ls_Name + ' 的同类' END IF IF ls_temp = 'Z' THEN ls_title = '添加 ' + ls_Name + ' 的子类' END IF IF ls_temp = 'M' THEN ls_title = '修改 ' Sle_1.text = ls_Name Sle_1.SelectText( 1, Len( ls_Name ) ) END IF title = ls_title end event type cb_2 from commandbutton within w_tv integer x = 727 integer y = 360 integer width = 457 integer height = 128 integer taborder = 20 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" string text = "退出(&E)" boolean cancel = true end type event clicked;CloseWithReturn( Parent, '' ) end event type cb_1 from commandbutton within w_tv integer x = 165 integer y = 360 integer width = 457 integer height = 128 integer taborder = 30 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" string text = "确定(&O)" boolean default = true end type event clicked;String ls_Name ls_Name = Trim( sle_1.text ) CloseWithReturn( Parent, ls_Name ) end event type sle_1 from singlelineedit within w_tv integer x = 64 integer y = 156 integer width = 1234 integer height = 128 integer taborder = 10 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type st_1 from statictext within w_tv integer x = 64 integer y = 40 integer width = 457 integer height = 72 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 33554432 long backcolor = 67108864 string text = "类别名称" boolean focusrectangle = false end type

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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