msgbartop
同一天地间,同一网络下,P9′Blog与您共享今日互联网→WWW.P9.NET.CN
msgbarbottom

VB美化的代码

代码:[code]Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Sub FormEffect(f As Form, Movement As Integer)
Dim myRect As RECT
Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
Dim TheScreen As Long
Dim Brush As Long
GetWindowRect f.hwnd, myRect '获得窗体四角的坐标
'计算窗体的高与宽
formWidth = myRect.Right - myRect.Left
formHeight = myRect.Bottom - myRect.Top
'得到屏幕的设备描述表句柄
TheScreen = GetDC(0)
'创建实色画刷
Brush = CreateSolidBrush(f.BackColor)
'将创建的画刷选入设备描述表中
SelectObject TheScreen, Brush
'从小到大依次绘制矩形,直到与窗体大小相同为止
For i = 1 To Movement
Cx = formWidth * (i / Movement)
Cy = formHeight * (i / Movement)
X = myRect.Left + (formWidth - Cx) / 2
Y = myRect.Top + (formHeight - Cy) / 2
Rectangle TheScreen, X, Y, X + Cx, Y + Cy
Next i
'释放
X = ReleaseDC(0, TheScreen)
'从内存中删除创建的画刷
DeleteObject (Brush)
End Sub

Public Sub ImplodeForm(f As Form, Direction As Integer, Movement As Integer, ModalState As Integer)

Dim myRect As RECT
Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
Dim TheScreen As Long
Dim Brush As Long

GetWindowRect f.hwnd, myRect
formWidth = (myRect.Right - myRect.Left)
formHeight = myRect.Bottom - myRect.Top
TheScreen = GetDC(0)
Brush = CreateSolidBrush(f.BackColor)

For i = Movement To 1 Step -1
Cx = formWidth * (i / Movement)
Cy = formHeight * (i / Movement)
X = myRect.Left + (formWidth - Cx) / 2
Y = myRect.Top + (formHeight - Cy) / 2
Rectangle TheScreen, X, Y, X + Cx, Y + Cy
Next i

X = ReleaseDC(0, TheScreen)
DeleteObject (Brush)

End Sub

Private Sub Form_Load()
FormEffect Me, 3000
End Sub[/code]

Leave a Comment

You must be logged in to post a comment.