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.339 mal aufgerufen.
Anzeige
![]() ![]() ![]() (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. |
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 Tipp des Monats ![]() Dieter Otter PopUp-Menü wird nicht angezeigt :-( In diesem Tipp verraten wir Ihnen, wie Sie Probleme mit PopUp-Menüs umgehen können, wenn diese unter bestimmten Umständen einfach nicht angezeigt werden. sevAniGif (VB/VBA) ![]() Anzeigen von animierten GIF-Dateien Ab sofort lassen sich auch unter VB6 und VBA (Access ab Version 2000) animierte GIF-Grafiken anzeigen und abspielen, die entweder lokal auf dem System oder auf einem Webserver gespeichert sind. |
||||||||||||||||
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. |