Adblock breaks this site

How to give your program cool fading effects when you close \ load

Discussion in 'Programming General' started by The True Gears, Jul 23, 2008.

  1. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    Put this code in Form1_load \ Form1_formclosing

    Code:
            Dim fade As Double
            For fade = 0.0 To 1.1 Step 0.1
                Me.Opacity = fade
                Me.Refresh()
                Threading.Thread.Sleep(100)
            Next
    Gives a pretty 1337 effect that most programs don't have :D
     
  2. drainingpower

    drainingpower Guru

    Joined:
    Jan 15, 2008
    Posts:
    1,166
    Referrals:
    0
    Sythe Gold:
    0
    How to give your program cool fading effects when you close \ load

    thanks :D i will definitely use this in my programs
    good job
     
  3. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    Thanks :D
     
  4. Rah915

    Rah915 Guest

    Referrals:
    0
    How to give your program cool fading effects when you close \ load

    Form closing:
    Code:
    Dim fade As Double
            For fade = 1.1 To 0.0 Step -0.1
                Me.Opacity = fade
                Me.Refresh()
                Threading.Thread.Sleep(100)
            Next
    that will make it fade out instead of fade in.
     
  5. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    How to give your program cool fading effects when you close \ load

    Terribly simple, however a lot of people seem to lack the ability to study such simple things, so I guess I can credit you for teaching.

    100ms sleep time is a bit much for fading. Perhaps 25 would do.
    Anyhow, converted to C#.

    fade in:
    Code:
    for(float fade = 0.0f; fade <= 1.1f; fade += 0.1f)
    {
        this.Opacity = fade;
        this.Invalidate();
        this.Update();
        System.Threading.Thread.Sleep(25);
    }
    fade out:
    Code:
    for(float fade = 1.1f; fade > 0.0f; fade -= 0.1f)
    {
        this.Opacity = fade;
        this.Invalidate();
        this.Update();
        System.Threading.Thread.Sleep(25);
    }
    I will point out that this is useless in Windows Vista, as the window manager already has such effects, except they are much more "aesthetically pleasing".
     
  6. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    Don't bug me about it...my point of posted it was to help new users...doesn't mean im one
     
  7. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    How to give your program cool fading effects when you close \ load

    I never said you were.
     
  8. 8arry 5tinkt

    8arry 5tinkt Guest

    Referrals:
    0
    How to give your program cool fading effects when you close \ load

    wow this looks really cool :D
     
  9. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    Thanks :D
     
  10. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    With a splashScreen that looks epic :D
     
  11. Kinglighter

    Kinglighter Active Member

    Joined:
    Aug 11, 2007
    Posts:
    102
    Referrals:
    0
    Sythe Gold:
    0
    How to give your program cool fading effects when you close \ load

    I' am new to VB and this totally rocks!
     
  12. Cymru

    Cymru Apprentice
    Banned

    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0
    How to give your program cool fading effects when you close \ load

    Thanks for the C# code :p
    this. never seems to work for me, but just putting opacity = fade; works
     
  13. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    How to give your program cool fading effects when you close \ load

    'this' is the keyword which refers to the containing class.

    i.e. in a class called MyClass, with an integer member called 'myint', you could refer to myint like so:

    Code:
    this.myint
     
  14. The True Gears

    The True Gears Guest
    $5 USD Donor

    Referrals:
    1
    How to give your program cool fading effects when you close \ load

    This thread is about as old as the internet, this is from when I actually cared about coding.

    I used to type like I was in 3rd grade ;_;
     
< So I've Been Trying To Make a VB6 Web Browser... | Youtube Downloader >


 
 
Adblock breaks this site