?? pushbutton.cls
字號(hào):
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsPushButton"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'********************************************
'聲明:
'********************************************
Option Explicit
'當(dāng)前屏幕上一個(gè)像素所包含的twip
Private Scale_X As Integer
Private Scale_Y As Integer
'當(dāng)前所繪按鈕的左上角坐標(biāo)值
Private baseTop As Integer
Private baseLeft As Integer
'********************************************
'聲明:
'********************************************
'*********************************************
'功能:類初始化函數(shù)
'*********************************************
Private Sub Class_Initialize()
Scale_X = Screen.TwipsPerPixelX
Scale_Y = Screen.TwipsPerPixelY
End Sub
'**********************************************
'功能:設(shè)置按鈕基準(zhǔn)點(diǎn)
'**********************************************
Public Sub SetBasePosition(left As Integer, top As Integer)
baseLeft = left
baseTop = top
End Sub
'**********************************************
'功能:綁定物體到Frame,此時(shí)限制按鈕容器為Frame
'參數(shù):fra:按鈕所在容器,此函數(shù)中為frame類型的
' shp:Shape類型的一個(gè)矩形
' pic:要求為一個(gè)PictureBox
' LineA:Line類型
' LineB:Line類型,這里四個(gè)參數(shù)所代表的控件將被設(shè)為以fra為容器
'**********************************************
Public Sub AttachObjectToFrame(ByRef fra As Frame, ByRef shp As Shape, ByRef pic As PictureBox, ByRef lineR As Line, ByRef lineB As Line)
Set pic.Container = fra
With pic
.top = baseTop
.left = baseLeft
.Visible = True '令其可見:不能漏
End With
Set shp.Container = fra
With shp
.left = pic.left - Scale_X
.top = pic.top - Scale_Y
.Visible = True
End With
Set lineR.Container = fra
With lineR
.X1 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y1 = pic.top
.X2 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y2 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.Visible = True
End With
Set lineB.Container = fra
With lineB
.X1 = pic.left
.Y1 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.X2 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y2 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.Visible = True
End With
End Sub
'**********************************************
'功能:綁定物體到Form,此時(shí)限制按鈕容器為Form
'參數(shù):fra:按鈕所在容器,此函數(shù)中為frame類型的
' shp:Shape類型的一個(gè)矩形
' pic:要求為一個(gè)PictureBox
' LineR:Line類型
' LineB:Line類型,這里四個(gè)參數(shù)所代表的控件將被設(shè)為以frm為容器
'**********************************************
Public Sub AttachObjectToForm(ByRef frm As Form, ByRef shp As Shape, ByRef pic As PictureBox, ByRef lineR As Line, ByRef lineB As Line)
Set pic.Container = frm
With pic
.top = baseTop
.left = baseLeft
.Visible = True '令其可見:不能漏
End With
Set shp.Container = frm
With shp
.left = pic.left - Scale_X
.top = pic.top - Scale_Y
.Visible = True
End With
Set lineR.Container = frm
With lineR
.X1 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y1 = pic.top
.X2 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y2 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.Visible = True
End With
Set lineB.Container = frm
With lineB
.X1 = pic.left
.Y1 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.X2 = pic.left + pic.ScaleWidth() + Scale_X * 2
.Y2 = pic.top + pic.ScaleHeight() + Scale_Y * 2
.Visible = True
End With
End Sub
'**********************************************
'功能:綁定物體到PictureBox
'參數(shù):pic:按鈕所用的PictureBox
' lab:顯示按鈕文本用的靜態(tài)文本框
' LineT:Line類型
' LineL:Line類型,這里三個(gè)參數(shù)所代表的控件將被設(shè)為以pic為容器
'**********************************************
Public Sub AttachObjectToPictureBox(ByRef pic As PictureBox, ByRef lab As Label, ByRef lineT As Line, ByRef lineL As Line)
Set lab.Container = pic
With lab
.AutoSize = True
.top = (pic.ScaleHeight - lab.Height) / 2 '設(shè)置位置
.left = (pic.ScaleWidth - lab.Width) / 2
.Visible = True '令其可見:不能漏
End With
Set lineT.Container = pic
With lineT
.BorderWidth = 1
.X1 = 0
.Y1 = 0
.X2 = pic.ScaleWidth()
.Y2 = 0
.Visible = True
End With
Set lineL.Container = pic
With lineL
.X1 = 0
.Y1 = 0
.X2 = 0
.Y2 = pic.ScaleHeight()
.Visible = True
End With
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -