Form opacity and custom panel paint problem

Hi everyone

I have a form with a few custom made panels that paint themselves, drawing a bunch of lines. Every second I call the Invalidate() method on each panel, which overrides the OnPaint() method. I have enabled doublebuffering and everything works flawless when running, except one quite annoying thing...

When the form is running with its opacity less than 1 and I start a 3D software in fullscreen I can see my forms paint events from within the 3D software. This means that I can see my forms drawing areas every second as flickering black boxes. This is very annoying and it only happens when the opacity is less than 1.

The 3D software I'm running is nVIDIAs GeoForms

I have tried to paint the panels without using the Invalidate() and paint events, but that makes no difference.

Anyone know how to get around this issue




Answer this question

Form opacity and custom panel paint problem

  • LKeene

    Although I use v91.47 drivers I hope your right about this, and until something else comes up I'll have to believe it's not my coding skills going off track, or the .Net framework for that matter :)

    Thanx for taking the time nobugz

  • DevDiver

    Hi nobugz

    Your test got me into some more testing, and actually I forgot to tell that the form I have is a borderless form. I set the borderstyle to SizableToolWindow with no title so I still have resizing abilities (I can enable / disable the border at runtime)

    Making a little change to your test code I was able to reproduce it, and found a more specific time when it "shines" through the 3D app.

    No border and low opacity is what makes it happen... turning on the border still with low opacity has no issues. I've changed your test code accordingly.

    private Panel panel1;
    private Timer timer1;
    public Form1()
    {
    InitializeComponent();
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.ControlBox = false;
    this.Text = "";
    Opacity = 0.6;
    panel1 = new Panel();
    panel1.Size = this.Size;
    panel1.Paint += panel1_Paint;
    Controls.Add(panel1);
    timer1 = new Timer();
    timer1.Enabled = true;
    timer1.Tick += timer1_Tick;
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
    panel1.Invalidate();
    }
    int ix = 0;
    private void panel1_Paint(object sender, PaintEventArgs e)
    {
    e.Graphics.DrawLine(Pens.Black, 0, 0, panel1.Width, ix);
    ++ix;
    if (ix > panel1.Height) ix = 0;
    }


  • ChrisHelt

    I've seen this effect before but I couldn't reproduce it. Here's the test code I used:

    using System;
    using System.Drawing;
    using System.Windows.Forms;

    namespace WindowsApplication1 {
    public partial class Form1 : Form {
    private Panel panel1;
    private Timer timer1;
    public Form1() {
    InitializeComponent();
    Opacity = 0.6;
    panel1 = new Panel();
    panel1.Size = this.Size;
    panel1.Paint += panel1_Paint;
    Controls.Add(panel1);
    timer1 = new Timer();
    timer1.Enabled = true;
    timer1.Tick += timer1_Tick;
    }
    private void timer1_Tick(object sender, EventArgs e) {
    panel1.Invalidate();
    }
    int ix = 0;
    private void panel1_Paint(object sender, PaintEventArgs e) {
    e.Graphics.DrawLine(Pens.Black, 0, 0, panel1.Width, ix);
    ++ix;
    if (ix > panel1.Height) ix = 0;
    }
    }
    }


  • nikos_22

    Yep, that did it. The problem disappears as soon as you display the form with a caption bar. You'll see something interesting when you put the form at (0, 0).

    I'm ready to call this a bug in either the GeoForms app or the NVidea drivers. The startup display for GeoForms is *very* unusual for a full-screen DirectX style app. For the record, I've got a GeForce Go 7400 adapter with driver version 8.2.4.9

    I'm going to uninstall GeoForms now, my laptop's fan has given me a chapped left-hand...


  • Form opacity and custom panel paint problem