Rubrik: Oberfläche · Effekte | VB-Versionen: VB4, VB5, VB6 | 22.12.00 |
Fenster-Effekte Die nachfolgenden Prozeduren zeigen ein paar nette Effekte zum Einblenden (Implode) und Ausblenden (Explode) von Fenstern. | ||
Autor: Dieter Otter | Bewertung: | Views: 24.002 |
www.tools4vb.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Die nachfolgenden Prozeduren zeigen ein paar nette Effekte zum Einblenden (Implode) und Ausblenden (Explode) von Fenstern.
' Zunächst alle benötigten API-Funktionen Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type 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 SetBkColor Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal crColor 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 "user32" ( _ ByVal hdc As Long, _ ByVal hObject As Long) As Long Private Declare Function DeleteObject Lib "gdi32" ( _ ByVal hObject As Long) As Long ' Ausblenden-Effekt Public Sub ExplodeForm(f As Form, Speed As Integer) Dim R As RECT Dim fWidth As Integer Dim fHeight As Integer Dim i As Integer Dim x As Integer Dim y As Integer Dim cx As Integer Dim cy As Integer Dim Desktop As Long Dim Brush As Long GetWindowRect f.hwnd, R fWidth = (R.Right - R.Left) fHeight = R.Bottom - R.Top Desktop = GetDC(0) Brush = CreateSolidBrush(f.BackColor) For i = 1 To Speed cx = fWidth * (i / Speed) cy = fHeight * (i / Speed) x = R.Left + (fWidth - Cx) / 2 y = R.Top + (fHeight - Cy) / 2 Rectangle Desktop, x, y, x + cx, y + cy Next i x = ReleaseDC(0, Desktop) DeleteObject (Brush) End Sub ' Einblenden-Effekt Public Sub ImplodeForm(f As Form, Speed As Integer) Dim R As RECT Dim fWidth As Integer Dim fHeight As Integer Dim i As Integer Dim x As Integer Dim y As Integer Dim cx As Integer Dim cy As Integer Dim Desktop As Long Dim Brush As Long GetWindowRect f.hwnd, R fWidth = (R.Right - R.Left) fHeight = R.Bottom - R.Top Desktop = GetDC(0) Brush = CreateSolidBrush(f.BackColor) For i = Speed To 1 Step -1 cx = fWidth * (i / Speed) cy = fHeight * (i / Speed) x = R.Left + (fWidth - Cx) / 2 y = R.Top + (fHeight - Cy) / 2 Rectangle Desktop, x, y, x + cx, y + cy Next i x = ReleaseDC(0, Desktop) DeleteObject (Brush) End Sub
Beispiel:
Private Sub Form_QueryUnload() ImplodeForm Me, 500 End Sub Private Sub Form_Unload() ExplodeForm Me, 500 End End Sub