前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

PowerBuilder制作IE风格的图标按钮 程序开发 - 电脑知识网 首 页硬件知识软件知识电脑百科网络知识操作系统应用软件杀毒安全电脑维修互联网数码产品程序开发网络设备外设知识笔记本手机通讯游戏知识数字家电多媒体配件知识耗材知识考试认证电脑常识电脑组装网站运营免费资源 您的位置: 电脑知识网 → 程序开发 PowerBuilder制作IE风格的图标按钮电脑知识网目录: → 程序开发 发布时间:2010-2-9 电脑知识网分分享PowerBuilder制作IE风格的图标按钮电脑知识,最全的程序开发知识库,感谢作者发布PowerBuilder制作IE风格的图标按钮,如果您喜欢本篇作文可以收藏起来,电脑知识网每天坚持更新程序开发,欢迎大家投稿得现金. PowerBuilder制作IE风格的图标按钮 关键字:数据库知识 电脑知识网www.qc99.com/diannao ---- 本文介绍在PowerBuilder中实现IE风格的图标按钮的技巧。电脑知识网www.qc99.com/diannao在C++ Builder开发工具中,有一种图标按钮(SpeedButton),这种按钮可以在鼠标移入按钮后,在图片的周围会出现凸出的边框,鼠标移出按钮后边框消失。而在PowerBuilder中没有提供这种功能的按钮,为了使开发的应用程序界面更丰富,我们使用自定义图形控件(Picture)扩展并实现了此功能,这种方法设计出的程序简洁实用。 ---- 一、实现功能 ---- 按钮可以显示四种状态图形: ---- 1、Normal状态; ---- 2、Disabled状态; ---- 3、MouseOver状态(鼠标进入按钮区); ---- 4、ClickDown状态(鼠标按下)。 ---- 二、关键方法 ---- 1、当鼠标进入按钮区域时,控件图片改换成MouseOver状态的图片,并设置状态信号; ---- 2、鼠标滑入按钮区域后用Windows API函数SetCapture来捕获鼠标输入消息,跟踪鼠标位置; ---- 3、当监测到鼠标滑出按钮区域时,用ReleaseCapture函数释放鼠标捕获,恢复按钮图片到Normal状态并设置状态信号; ---- 4、改变控件的图片(PictureName)前,先用ReleaseCapture释放鼠标捕获,然后改变PictureName属性值,接着重新调用SetCapture函数,因为改变图片后PowerBuilder重新建立了控件窗口,窗口的句柄(hWnd)也随之改变了。 ---- 三、设计过程 ---- 1、新建“User Object” -〉选择Visual的Standard类 -〉选择“Picture”; ---- 2、定义全局的或局部的外部函数: // ******************************* // Declare External Functions // ******************************* function ulong SetCapture (ulong hwnd) library "user32.dll" function boolean ReleaseCapture (ulong hwnd) library "user32.dll" function boolean DrawEdge(ulong hdc, ref rect qrc, uint edge, uint grfFlags) library "user32.dll" ---- 3、定义结构数据类型 RECT { long left long top long right long bottom } ---- 4、定义控件共享变量: // ******************************* // Declare Shared Variables // ******************************* boolean sb_SuppressHoverBorder ---- 5、定义控件实例变量: // ******************************* // Declare Instance Variables // ******************************* Private: boolean ib_MouseCaptured Public: string is_PicNormal string is_PicDisabled string is_PicMouseOver string is_PicClickDown int in_State ---- 6、定义用户事件: // ******************************* // Declare User Events // ******************************* Event Name="mousemove", ID="pbm_mousemove" Event Name="lbuttondown", ID="pbm_lbuttondown" Event Name="lbuttonup", ID="pbm_lbuttonup" ---- 7、编写事件代码: // “Constructor” 事件代码 // *** begin constructor event *** // is_PicNormal = this.PictureName is_PicDisabled = "Disabled状态图片.bmp" is_PicMouseOver = "MouseOver状态图片.bmp" is_PicClickDown = "ClickDown状态图片.bmp" in_State = 0 sb_SuppressHoverBorder = FALSE // // *** end constructor event *** // “MouseMove” 事件代码 // *** begin mousemove event *** // rect lr_Border if not ib_MouseCaptured then if flags < > 1 then this.PictureName = is_PicMouseOver else // Left Button Down this.PictureName = is_PicClickDown end if in_State = 1 SetCapture(handle(this)) ib_MouseCaptured = TRUE if not sb_SuppressHoverBorder then lr_Border.left = 0 lr_Border.top = 0 lr_Border.right = UnitsToPixels (this.Width, XUnitsToPixels!) lr_Border.bottom = UnitsToPixels (this.Height, YUnitsToPixels!) if flags < > 1 then DrawEdge(GetDC(handle(this)), lr_Border, 4, 1+2+4+8) else // Left Button Down DrawEdge(GetDC(handle(this)), lr_Border, 2, 1+2+4+8) end if end if else // 检测鼠标是否滑出按钮区域? if (XPos < 0 or YPos < 0) or (XPos > this.Width or YPos > this.Height) then ib_MouseCaptured = FALSE ReleaseCapture() in_State = 0 this.PictureName = is_PicNormal end if end if return 1 // // *** end mousemove event *** // “LButtonDown” 事件代码 // *** begin lbuttondown event *** // rect lr_Border if ib_MouseCaptured then ib_MouseCaptured = FALSE ReleaseCapture() end if in_State = 2 this.PictureName = is_PicClickDown SetCapture(handle(this)) ib_MouseCaptured = TRUE if not sb_SuppressHoverBorder then lr_Border.left = 0 lr_Border.top = 0 lr_Border.right = UnitsToPixels (this.Width, XUnitsToPixels!) lr_Border.bottom = UnitsToPixels (this.Height, YUnitsToPixels!) DrawEdge(GetDC(handle(this)), lr_Border, 2, 1+2+4+8) end if return 1 // // *** end lbuttondown event *** // “LButtonUp” 事件代码 // *** begin lbuttonup event *** // rect lr_Border if ib_MouseCaptured then ib_MouseCaptured = FALSE ReleaseCapture() end if if (XPos < 0 or YPos < 0) or (XPos > this.Width or YPos > this.Height) then in_State = 0 this.PictureName = is_PicNormal else in_State = 1 this.PictureName = is_PicHover SetCapture(handle(this)) ib_MouseCaptured = TRUE if not sb_SuppressHoverBorder then lr_Border.left = 0 lr_Border.top = 0 lr_Border.right = UnitsToPixels (this.Width, XUnitsToPixels!) lr_Border.bottom = UnitsToPixels (this.Height, YUnitsToPixels!) DrawEdge(GetDC(handle(this)), lr_Border, 4, 1+2+4+8) end if end if // 产生Clicked事件 this.event post clicked() return 1 // // *** end lbuttonup event *** // “Other” 事件代码 // *** begin other event *** // if message.number = 533 and ib_MouseCaptured then // wm_CaptureChanged ib_MouseCaptured = FALSE in_State = 0 this.PictureName = is_PicNormal return 1 end if return 0 // // *** end other event *** ----  四、简要说明 ---- 1、ib_MouseCaptured变量是作为MouseMove事件的刷新控件图片的信号灯及判断是否已安装了鼠标捕捉器; ---- 2、sb_SuppressHoverBorder变量,默认值为FALSE,当值为TRUE时,控件不绘制凸或凹边框; ---- 3、“Other”事件,当鼠标捕捉器被释放或被替换时会触发WM_CAPTURECHANGED事件,例如:您在Clicked事件中调用MessageBox函数时,将触发WM_CAPTURECHANGED事件,在此事件代码中恢复按钮到Normal状态。 《PowerBuilder制作IE风格的图标按钮》相关电脑知识 自适应屏幕分辨率的基类窗口VFP右键功能Eclipse+JBoss+MySQL开发环境设置MySQL安装与使用怎样快速查出Oracle数据库中的锁等待使用PowerBuilder同时访问多个数据库使用Oracle9i数据库的注意事项为PB的TreeView实现同步选择Visual Foxpro生成任意打印字段报表的实现教你5分钟做成一个ASP论坛别让MsgBox中断了一些Background的处理作业设置 MySql 数据同步 添加《PowerBuilder制作IE风格的图标按钮》到书签: ·上一篇:用FoxWeb在网上快速发布你的FOXPRO数据库 ·下一篇:如何实现SQL Server数据库的备份与恢复 推荐电脑知识MP5是否存在 为什么迅雷下载很慢 DIY高手入门教程 主板故障与维修基础篇 电脑开不了机 怎么样让电脑自动关机??? 我的电脑昨天还好的!我今天在启动时出现滴滴报警声 ! 为什么我街头篮球几乎不绿 内存文件的问题 主板常见故障的处理方法 专家教你三分钟解决主板问题 富士Z100fd 读不到卡 LGKF350和诺基亚7610S那个机子好 PSP能不能通过笔记本自带的无线网卡上网? 最新免费电脑知识 范文网 网站地图 合作伙伴 隐私保护 版权声明 联系我们电脑知识网,电脑爱好者之家与您分享PowerBuilder制作IE风格的图标按钮,解决电脑故障,电脑问题,分享电脑维修技巧,提供最全的程序开发学习库,电脑知识网是您学习电脑知识的最好选择! www.qc99.com/diannao 电脑知识网 版权所有 &copy;2005-2012