Auf MSDN findet man die Beschreibung der Animationsmöglichkeiten von Fenstern. Die folgende Klasse stellt diese Möglichkeiten ins VB-Umfeld so zu sagen. Imports System.Windows.Forms Imports System.Drawing, System.Runtime.InteropServices Imports System.Security, System.Security.Permissions Namespace AnimatedWindow Friend NotInheritable Class AnimationMethods Private Const AW_ACTIVATE = &H20000 Private Const AW_BLEND = &H80000 Private Const AW_CENTER = &H10 Private Const AW_SLIDE = &H40000 Private Const AW_HIDE = &H10000 Private Const AW_HOR_POSITIVE = &H1 Private Const AW_HOR_NEGATIVE = &H2 Private Const AW_VER_POSITIVE = &H4 Private Const AW_VER_NEGATIVE = &H8 Private Const WM_PAINT = &HF <Flags()> _ Public Enum AnimationFlags As Integer ' Activates the window. Activate = AW_ACTIVATE ' Uses a fade effect. This flag can be used ' only with a top-level window. Blend = AW_BLEND ' Makes the window appear to collapse inward if Hide ' is used or expand outward if the Hide is not used. Center = AW_CENTER ' Hides the window. By default, the window is shown. Hide = AW_HIDE ' Animates the window from left to right. This flag ' can be used with roll or slide animation. HorizontalPositive = AW_HOR_POSITIVE ' Animates the window from right to left. This flag ' can be used with roll or slide animation. HorizontalNegative = AW_HOR_NEGATIVE ' Uses a slide animation. By default, roll animation is used. Slide = AW_SLIDE ' Uses a roll animation. Roll = &H0 ' Animates the window from top to bottom. This flag ' can be used with roll or slide animation. VerticalPositive = AW_VER_POSITIVE ' Animates the window from bottom to top. This flag ' can be used with roll or slide animation. VerticalNegative = AW_VER_NEGATIVE End Enum <SuppressUnmanagedCodeSecurity()> _ <DllImport("user32.dll", CharSet:=CharSet.Auto)> _ Private Shared Function AnimateWindow(ByVal windowHandle As HandleRef, _ ByVal time As Integer, ByVal flags As AnimationFlags) As Integer End Function Friend Shared Sub AnimateWindow(ByVal control As Control, _ ByVal time As Integer, ByVal flags As AnimationFlags) Try Dim sp As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode) sp.Demand() AnimateWindow(New HandleRef(control, control.Handle), time, flags) Catch generatedExceptionName As SecurityException End Try End Sub End Class End Namespace Am besten wendet man die Animation im VisibleChanged-Ereignis der Form an. Private Sub myForm_VisibleChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.VisibleChanged If Me.Visible Then AnimatedWindow.AnimationMethods.AnimateWindow(Me, 200, _ AnimatedWindow.AnimationMethods.AnimationFlags.Activate Or _ AnimatedWindow.AnimationMethods.AnimationFlags.VerticalPositive Or _ AnimatedWindow.AnimationMethods.AnimationFlags.HorizontalPositive) Else AnimatedWindow.AnimationMethods.AnimateWindow(Me, 200, _ AnimatedWindow.AnimationMethods.AnimationFlags.Hide Or _ AnimatedWindow.AnimationMethods.AnimationFlags.VerticalNegative Or _ AnimatedWindow.AnimationMethods.AnimationFlags.HorizontalNegative) End If End Sub Die Form wird in diesem Falle bei 'myForm.Show' von links-oben nach rechts-unten aufgemacht und beim Schließen von rechts-unten nach links-oben ausgeblendet. Dieser Tipp wurde bereits 9.633 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! sevCoolbar 3.0 Professionelle Toolbars im modernen Design! Mit sevCoolbar erstellen Sie in wenigen Minuten ansprechende und moderne Toolbars und passen diese optimal an das Layout Ihrer Anwendung an (inkl. große Symbolbibliothek) - für VB und MS-Access Tipp des Monats April 2024 Skyfloy Chart von Microsoft und dazu noch gratis Tutorial für Microsoft Chart Controls für Microsoft .NET Framework 3.5 TOP Entwickler-Paket TOP-Preis!! Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR... |
||||||||||||||||
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. |