2

For my application im making "Toast" like alerts. Im using an override method on the forms "Paint" event to create a custom gradient. The form then has a picture box, and 3 labels on it, all with transparent backgrounds. On XP, the background of these controls are being set to the form's original background color, and the images / text not being displayed.

On windows 7:

Windows 7 Display

On Windows XP:

Windows XP Display

My Paint method:

    private void AlertForm_Paint(object sender, PaintEventArgs e)
    {
        using (LinearGradientBrush brush = new LinearGradientBrush(
            this.ClientRectangle,
            Color.Black,
            Color.DimGray,
            120F))
        {
            e.Graphics.FillRectangle(brush, this.ClientRectangle);
        }
    }

Does anyone have any advice to fix the issues on windows XP please?

UPDATE: Here is the source code to my form, minus design code: http://pastebin.com/RUYtM7qu

FIXED: I have found the issue to be due to the animation of the form. If i just show the form, it displays fine, but as soon as i move it, the text and icon disapear. I decided to register for the "LocationChanged" event, and manually call this.Refresh()" on the form, and that fixed the problem!

Steven Wilson
  • 65
  • 1
  • 1
  • 7
  • If you remove the `FillRectangle` call does it show ok on XP? – lc. Jul 10 '13 at 15:45
  • No it does not. The backgrounds are still filled with black – Steven Wilson Jul 10 '13 at 15:52
  • Possibly helpful: http://stackoverflow.com/a/605944/44853 and the answer it links to – lc. Jul 10 '13 at 15:56
  • I don't think this is an issue of XP, I used XP before and it rendered many third party controls (such as from DevExpress which supports many skinny controls in winforms) OK. – King King Jul 10 '13 at 16:13
  • Using the transparent label as posted by LC works... but the foreground text is still missing – Steven Wilson Jul 10 '13 at 16:31
  • This code works fine on XP. I've created a new project, added a pictureBox, 3 labels, used the above code, set an image for the pictureBox, set the backColor of the labels to Transparent and the form's opacity to 70%. – David - Jul 10 '13 at 17:22
  • Well, my form is using a timer as well, that is sliding the form up every 20 milliseconds until the form is displayed just above the taskbar. Here is the complete source to my form (minus designer stuff) http://pastebin.com/RUYtM7qu – Steven Wilson Jul 10 '13 at 17:36

0 Answers0