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 Dieser Tipp wurde bereits 24.009 mal aufgerufen. Voriger Tipp | Zufälliger Tipp | Nächster Tipp
Anzeige
Diesen und auch alle anderen Tipps & Tricks finden Sie auch auf unserer aktuellen vb@rchiv Vol.6 (einschl. Beispielprojekt!) Ein absolutes Muss - Geballtes Wissen aus mehr als 8 Jahren vb@rchiv! - nahezu alle Tipps & Tricks und Workshops mit Beispielprojekten - Symbol-Galerie mit mehr als 3.200 Icons im modernen Look Weitere Infos - 4 Entwickler-Vollversionen (u.a. sevFTP für .NET), Online-Update-Funktion u.v.m. |
Neu! sevEingabe 3.0 Einfach stark! Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Tipp des Monats Mai 2024 Hermann Röttger Wochentage eines Datumsbereichs ermitteln Wochentage eines Datumsbereichs ermitteln, optional mit Feiertagsberechnung Access-Tools Vol.1 Über 400 MByte Inhalt Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB |
||||||||||||||||
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein. |