1

Needless to say, my GooglFu is weak today.

I have a small WinForm, that has, as it's background, an asymmetrical image. To accommodate this image, the form itself is a bit larger than the image itself.

I have the forms background color set to LightSalmon as well as the form's TransparencyKey.

I don't think it's totally necessary to post the code (I think it came from CodeProject) that does this little bit, but, just in case, I have included it as well.

The FadeIn:

    private void opTimer_Tick(object sender, EventArgs e)
    {
        if (opacityIncrease > 0)
        {
            if (this.Opacity < 1)
                this.Opacity += opacityIncrease;
        }
        else
        {
            if (this.Opacity > 0)
                this.Opacity += opacityIncrease;
            else
                this.Close();
        }
    }

The FadeOut (called on formClosing event)

    public void FadeForm()
    {
        opacityIncrease = -opacityDecrease;
    }

The code works as it should, but, the problem lies when the form is fading in and out. As the form fades in, I can see the forms background, that awful LightSalmon. Once the form has reached full Opacity, the background is, indeed, fully transparent.

Is there a way to keep the TransparencyKey color (the forms background), well, Transparent during the fade-in/out?

The easiest solution would be to change the forms background image to one that fit's the form without having to bother with the whole TransparencyKey business, but, I rather like the image that I am using, but, it's certainly not a ShowStopper to change it to something else.

Using VS2008, .NET 3.5

As always, happy to answer any follow-up questions if necessary.

Thanks.

Jasoomian
  • 179
  • 2
  • 13
  • What does the background colour of the form get reported as during the fade? If it's not LightSalmon, can you just update the transparency colour to the new background colour each timer tick? – Xav Aug 17 '11 at 15:19
  • The forms BackColor property remains at LightSalmon throughout the FadeIn and FadeOut process. – Jasoomian Aug 17 '11 at 16:06

1 Answers1

0

I Can guess that the Fadeout\Fadein changes the Pixel value and thus it is not equal to the transparent key.

only when it is equal it becomes transparent again.

if you can, try bounding the fade out/in section to not include the LightSalmon Area - it should stay in the same pixels value and stay transparent always.

briler
  • 570
  • 6
  • 21
  • Thanks for the input briler. Unfortunately, the app (although internal) had to be released before I could get a chance to implement your suggestions. The next time I get a chance to work on said app, I'll give your answer the good ol' college try and see if I can get it to work. Thanks again. – Jasoomian Sep 15 '11 at 14:15