Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Splash Screen Form

Splash Screen Form

Scheduled Pinned Locked Moved C#
graphicsbusinesstutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    see_seA
    wrote on last edited by
    #1

    I'm trying to make a splash screen with the following requirements: 1) Must fade in and fade out (issues) 2) Fades in before main program form is open and fades out once it is (done this) 3) Displays an image which is not squash and has transparency (issues) So I've looked on the net and I'm still struggling with some aspects if anyone can assist. Fading the form is trivial (by setting the Opacity), however getting a form to be transparent (to work with the pictures transparency) and then fading that in and out is a mess. I have tried numerous methods, such as overriding OnPaintBackground, changing the style of a form to allow a transparent background and a few other things. The problems I hit are: - When fading the transparent form, by changing the Opacity the transparent bits turn black - When the splash screen first shows it paints properly, but when the main form is finally loaded the transparent bits of the splash screen still show what was there before the form loaded (i.e. not repainting or something). At the moment some of the code I have looks like this:

        protected override void OnPaint(PaintEventArgs e)
        {
            // Do nothing here!
        }
    
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Console.WriteLine("paintBackground");
            Graphics gfx = e.Graphics;
            gfx.DrawImage(global::DesktopLiveDotNet.Properties.Resources.splash\_screen, new Rectangle(0, 0, Width, Height));
        }
    

    But when it starts to fade the transparency turns black:

        private void timer1\_Tick(object sender, EventArgs e)
        {
            Opacity = fOpacity / 100;
            
            Application.DoEvents();
            fOpacity -= StepVal;
    
            if (fOpacity <= 0)
            {
                timer1.Stop();
                Close();
            }
        }
    

    Not quite sure how to proceed and any ideas would be great! :)

    L 1 Reply Last reply
    0
    • S see_seA

      I'm trying to make a splash screen with the following requirements: 1) Must fade in and fade out (issues) 2) Fades in before main program form is open and fades out once it is (done this) 3) Displays an image which is not squash and has transparency (issues) So I've looked on the net and I'm still struggling with some aspects if anyone can assist. Fading the form is trivial (by setting the Opacity), however getting a form to be transparent (to work with the pictures transparency) and then fading that in and out is a mess. I have tried numerous methods, such as overriding OnPaintBackground, changing the style of a form to allow a transparent background and a few other things. The problems I hit are: - When fading the transparent form, by changing the Opacity the transparent bits turn black - When the splash screen first shows it paints properly, but when the main form is finally loaded the transparent bits of the splash screen still show what was there before the form loaded (i.e. not repainting or something). At the moment some of the code I have looks like this:

          protected override void OnPaint(PaintEventArgs e)
          {
              // Do nothing here!
          }
      
          protected override void OnPaintBackground(PaintEventArgs e)
          {
              Console.WriteLine("paintBackground");
              Graphics gfx = e.Graphics;
              gfx.DrawImage(global::DesktopLiveDotNet.Properties.Resources.splash\_screen, new Rectangle(0, 0, Width, Height));
          }
      

      But when it starts to fade the transparency turns black:

          private void timer1\_Tick(object sender, EventArgs e)
          {
              Opacity = fOpacity / 100;
              
              Application.DoEvents();
              fOpacity -= StepVal;
      
              if (fOpacity <= 0)
              {
                  timer1.Stop();
                  Close();
              }
          }
      

      Not quite sure how to proceed and any ideas would be great! :)

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      I have never been able to use BackGroundpainting successfully. Why not just paint normally?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      S 1 Reply Last reply
      0
      • L leppie

        I have never been able to use BackGroundpainting successfully. Why not just paint normally?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        S Offline
        S Offline
        see_seA
        wrote on last edited by
        #3

        I've tried that. My problem is making the form's background disappear. I cannot get rid of the grey square (default form background color). So to do that I override the paintbackground method but that then draws black wherever the transparency is meant to be. Whether double buffered or not. It definitely draws black in the transparency when changing Opacity :/

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups