您现在的位置:动易网络>> 帮助文档>> PowerBuilder>>正文内容

在窗口中实现实时帮助条

    中文之星2.0版的链形菜单管理器提供了实时帮助条,增强了系统的易用性,在PowerBuilder中也可以实现类似的功能。当鼠标移动到窗口中的某些控制(Control),如编辑器、图片等时,会在鼠标附近自动产生帮助条,实时地提示操作要领。
首先在窗口w_main中任意位置定义一个黄底黑字的静态文本st_help,
设定st_help.visible=false,st_help.text=&Help;
然后在该窗口模块的Declare\WindowFunctions...下定义函数show_help(),
其参数只有一个,参数名为text,类型为string,通过传值方式接收参数;无返值。
show_help()代码如下:
if st_help.visible then
   return
end if
st_help.text=text
st_help.width=Len(st_help.text)*38
st_help.x=w_main.PointerX()
st_help.y=w_main.PointerY()+50
if st_help.x+st_help.width>w_main.Workspacewidth() then
   st_help.x=w_main.Workspacewidth()-st_help.width
endif
if st_help.y+st_help.height>w_main.Workspaceheight() then
   st_help.y=w_main.Workspaceheight()-st_help.height
endif
st_help.visible=true
接下来,我们就可以调用show_help()函数了。但PowerBuilder提供的所有控制均缺乏当鼠标移至其上就触发的事件,显然,需要定义相应的用户事件。先选中准备定义用户事件的控制,如某个单行编辑器,然后在窗口模块的菜单Declare\UserEvents...下,双击PasteEventID:中的pbm_mousemove条目,将其拷贝至EventID下,取EventName为Mouseon,这样,我们就定义好了相应控制的用户事件Mouseon。我们可以在该控制的用户事件Mouseon下,写下调用函数show_help()的语句:
if st_help.visiblethenHide(st_help)
   show_help("瞧!这便是实时帮助条!")
end if
 


感动 同情 无聊 愤怒 搞笑 难过 高兴 路过
【字体: 】【收藏】【打印文章】【查看评论

相关文章

    没有相关内容