论坛: 编程破解 标题: VB窗体启用特效 复制本贴地址    
作者: hongliubo1 [hongliubo1]    论坛用户   登录
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

地主 发表时间: 05-01-14 21:31

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号