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.622 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. |
sevISDN 1.0 Überwachung aller eingehender Anrufe! Die DLL erkennt alle über die CAPI-Schnittstelle eingehenden Anrufe und teilt Ihnen sogar mit, aus welchem Ortsbereich der Anruf stammt. Weitere Highlights: Online-Rufident, Erkennung der Anrufbehandlung u.v.m. 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 sevZIP40 Pro DLL Zippen und Unzippen wie die Profis! Mit nur wenigen Zeilen Code statten Sie Ihre Anwendungen ab sofort mit schnellen Zip- und Unzip-Funktionen aus. Hierbei lassen sich entweder einzelnen Dateien oder auch gesamte Ordner zippen bzw. entpacken. |
||||||||||||||||
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. |