• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

实现浮动按钮

发布: 2007-7-14 20:28 | 作者: 佚名    | 来源: 网络转载     | 查看: 11次 | 进入软件测试论坛讨论

领测软件测试网 程序里面使用了浮动按钮,可以使程序看起来更美观和更容易使用。实现的方法是首先建立四条Line。和一个Image的控件,在程序根目录下把图标先改成macos.ico或者把程序相应更改一下图标文件的名字。然后代码如下:


Private Sub Form_Load()
Image1.Picture = LoadPicture(App.Path & "\macos.ico")

'使Line控件不可见
Line1.Visible = False
Line2.Visible = False
Line3.Visible = False
Line4.Visible = False

'调整Line1控件在Image1的左边,并调整大小
Line1.X1 = Image1.Left - 1
Line1.Y1 = Image1.Top - 1
Line1.X2 = Line1.X1
Line1.Y2 = Image1.Top + Image1.Height + 1

'调整Line2控件在Image1的上面,并调整大小
Line2.X1 = Image1.Left - 1
Line2.Y1 = Image1.Top - 1
Line2.X2 = Image1.Top + Image1.Height + 1
Line2.Y2 = Line1.Y1

'调整Line3控件在Image1的右边,并调整大小
Line3.X1 = Line2.X2
Line3.Y1 = Line2.Y1
Line3.X2 = Line2.X2
Line3.Y2 = Line1.Y2

'调整Line4控件在Image1的下面,并调整大小
Line4.X1 = Line1.X1
Line4.Y1 = Line1.Y2
Line4.X2 = Line2.X2
Line4.Y2 = Line1.Y2

'按钮凸起效果
Line1.BorderColor = QBColor(15) '白色
Line2.BorderColor = QBColor(15) '白色
Line3.BorderColor = QBColor(0)  '黑色
Line4.BorderColor = QBColor(0)  '黑色
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Line1.Visible = True Then
'防止无意义调用下列语句
Line1.Visible = False
Line2.Visible = False
Line3.Visible = False
Line4.Visible = False
Image1.Picture = LoadPicture(App.Path & "\macos.ico")
End If
End Sub

Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'左键
If Button = 1 Then
Line1.BorderColor = QBColor(0)
Line2.BorderColor = QBColor(0)
Line3.BorderColor = QBColor(15)
Line4.BorderColor = QBColor(15)
End If
MsgBox "Jason guo提醒你!要好好学习VB哦!!!"
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Line1.Visible = False Then
'防止无意义调用下面语句
Line1.Visible = True
Line2.Visible = True
Line3.Visible = True
Line4.Visible = True
Image1.Picture = LoadPicture(App.Path & "\macos.ico")
End If
End Sub

Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'右键
If Button = 1 Then
Line1.BorderColor = QBColor(15)
Line2.BorderColor = QBColor(15)
Line3.BorderColor = QBColor(0)
Line4.BorderColor = QBColor(0)
End If
End Sub

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网