Manfred Skrevet 16. mai 2007 Del Skrevet 16. mai 2007 (endret) Jeg har følgende kode: protected override void OnDeactivate(EventArgs e) { base.OnDeactivate(e); for (double d = 0.5; d > 0.0; d -= 0.1) { Opacity = d; System.Threading.Thread.Sleep(100); } Visible = false; Opacity = 1.0; } for å fade ut programmet OnDeactivate. Men denne gjør bare at jeg får en Grå firkant, som fader ut. Jeg vil at man skal se hele vinduet fade ut. Hvordan får man til dette? Endret 16. mai 2007 av Manfred Lenke til kommentar
Manfred Skrevet 16. mai 2007 Forfatter Del Skrevet 16. mai 2007 Løsningen er å legge til denne klassen: Klikk for å se/fjerne innholdet nedenfor using System; using System.Runtime.InteropServices; namespace MyNameSpace { /// <summary> /// Win32 implementation to show / hide a window with animation. /// </summary> public class WinAPI { /// <summary> /// Animates the window from left to right. This flag can be used with roll or slide animation. /// </summary> public const int AW_HOR_POSITIVE = 0X1; /// <summary> /// Animates the window from right to left. This flag can be used with roll or slide animation. /// </summary> public const int AW_HOR_NEGATIVE = 0X2; /// <summary> /// Animates the window from top to bottom. This flag can be used with roll or slide animation. /// </summary> public const int AW_VER_POSITIVE = 0X4; /// <summary> /// Animates the window from bottom to top. This flag can be used with roll or slide animation. /// </summary> public const int AW_VER_NEGATIVE = 0X8; /// <summary> /// Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used. /// </summary> public const int AW_CENTER = 0X10; /// <summary> /// Hides the window. By default, the window is shown. /// </summary> public const int AW_HIDE = 0X10000; /// <summary> /// Activates the window. /// </summary> public const int AW_ACTIVATE = 0X20000; /// <summary> /// Uses slide animation. By default, roll animation is used. /// </summary> public const int AW_SLIDE = 0X40000; /// <summary> /// Uses a fade effect. This flag can be used only if hwnd is a top-level window. /// </summary> public const int AW_BLEND = 0X80000; /// <summary> /// Animates a window. /// </summary> [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int AnimateWindow (IntPtr hwand , int dwTime , int dwFlags); } } Og så bruker jeg denne koden: WinAPI.AnimateWindow(this.Handle, 1000, WinAPI.AW_HIDE | WinAPI.AW_BLEND); Lenke til kommentar
Moskus Skrevet 21. mai 2007 Del Skrevet 21. mai 2007 TAKK! Har lett etter slik funksjon! Lenke til kommentar
Manfred Skrevet 21. mai 2007 Forfatter Del Skrevet 21. mai 2007 Regnet med noen andre også hadde lett etter noe slikt. Derfor jeg publiserte løsningen også Lenke til kommentar
Spartakus Skrevet 21. mai 2007 Del Skrevet 21. mai 2007 (endret) Det er bra du publiserer det du har funnet, i motsetning til andre som redigerer posten og heller skriver "glem det, fant det ut selv".... Endret 21. mai 2007 av xtc Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå