VB辅导 窗体换肤
来源:优易学  2011-4-6 10:41:34   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  ’如果出现异常错误,则恢复默认的背景图片
  ErrorPic:
  If Err.Number = 481 Then
  MsgBox " Picture File Error!"
  End If
  If BackPicture <> App.Path + "default.JPG" Then
  BackPicture = App.Path + "default.JPG"
  Set Pic = LoadPicture(BackPicture)
  Resume Next
  Else
  ’ShowBorder Frm
  End If
  End Sub
  ’---------------------------------------------
  ’如果我们不想使用默认的标题栏和边框,而自己制作更漂
  ’亮的标题栏,可把窗体Frmmain的Border属性设为0-None
  ’利用下面的ShowBorder来重新画出窗体的Border,别忘
  ’了把上面中的ShowBackGround子过程的ShowBorder Frm
  ’写上。
  ’---------------------------------------------
  ’Sub ShowBorder(Frm As Form)
  ’Frm.DrawWidth = 1
  ’Frm.Line (Frm.ScaleWidth - 1, 1)-(Frm.ScaleWidth - 1, Frm.ScaleHeight - 1), QBColor(1)
  ’Frm.Line (Frm.ScaleWidth - 2, 2)-(Frm.ScaleWidth - 2, Frm.ScaleHeight - 2), QBColor(8)
  ’Frm.Line (Frm.ScaleWidth - 3, 3)-(Frm.ScaleWidth - 3, Frm.ScaleHeight - 3), QBColor(7)
  ’Frm.Line (1, Frm.ScaleHeight - 1)-(Frm.ScaleWidth - 1, Frm.ScaleHeight - 1), QBColor(1)
  ’Frm.Line (2, Frm.ScaleHeight - 2)-(Frm.ScaleWidth - 2, Frm.ScaleHeight - 2), QBColor(8)
  ’Frm.Line (3, Frm.ScaleHeight - 3)-(Frm.ScaleWidth - 3, Frm.ScaleHeight - 3), QBColor(7)
  ’Frm.Line (0, 0)-(Frm.ScaleWidth, 0), QBColor(7)
  ’Frm.Line (1, 1)-(Frm.ScaleWidth - 1, 1), QBColor(15)
  ’Frm.Line (2, 2)-(Frm.ScaleWidth - 2, 2), QBColor(7)
  ’Frm.Line (0, 0)-(0, Frm.ScaleHeight), QBColor(7)
  ’Frm.Line (1, 1)-(1, Frm.ScaleHeight - 1), QBColor(15)
  ’Frm.Line (2, 2)-(2, Frm.ScaleHeight - 2), QBColor(7)
  ’End Sub
  程序每次运行时都会到程序所在的目录下找default.bmp文件,如果找到这个文件,它就会把这张图片作为窗体的背景,这样我们可以用自己喜欢的图片替换这张图,也就是为程序“换肤”,另外程序运行过程中也可动态的改变窗体的背景图片。

上一页  [1] [2] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训