Paintdesktop Api with back buffer
-
Hi all. I'm trying to use the paintdesktop api call in a c# application. I'm using the following code in the paint event of the form, but this causes a lot of flickering when it draws.
Graphics g = this.CreateGraphics(); // Create compatible graphics object IntPtr hdc = g.GetHdc(); // Get HDC of graphics PaintDesktop(hdc); // Draw the system wallpaper g.ReleaseHdc(); // Release HDC so other drawing can take place g.DrawImage(Interface, 0, 0); // Draw the interface over wallpaper g.Dispose(); // Dispose graphics object
I presume that I need to use some form of backbuffering to stop this flickering, however trying to draw the wallpaper with paintdesktop to a system.drawing.bitmap fails. I *think* I would be able to draw it to a bitmap created with the api createbitmap, but don't really know how to use this call or then get a HDC to such a bitmap and haven't been able to find any simple instructions for .net. Can anyone provide a sample or a link to an *easy* article which explains it, or suggest another way reduce the flickering? Or does anyone have any experience with or links to articles about paintdesktop with .net that they could share? Thanks!
-
Hi all. I'm trying to use the paintdesktop api call in a c# application. I'm using the following code in the paint event of the form, but this causes a lot of flickering when it draws.
Graphics g = this.CreateGraphics(); // Create compatible graphics object IntPtr hdc = g.GetHdc(); // Get HDC of graphics PaintDesktop(hdc); // Draw the system wallpaper g.ReleaseHdc(); // Release HDC so other drawing can take place g.DrawImage(Interface, 0, 0); // Draw the interface over wallpaper g.Dispose(); // Dispose graphics object
I presume that I need to use some form of backbuffering to stop this flickering, however trying to draw the wallpaper with paintdesktop to a system.drawing.bitmap fails. I *think* I would be able to draw it to a bitmap created with the api createbitmap, but don't really know how to use this call or then get a HDC to such a bitmap and haven't been able to find any simple instructions for .net. Can anyone provide a sample or a link to an *easy* article which explains it, or suggest another way reduce the flickering? Or does anyone have any experience with or links to articles about paintdesktop with .net that they could share? Thanks!
Hi, I Created an application that allows user to draw shapes, pictures,... I had also flickering problem and a single line of code resolved my problem. Try this line in the Initilization of ure Control/Form : SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Change the first argument to ure needs. HTH. Hayder Marzouk
-
Hi, I Created an application that allows user to draw shapes, pictures,... I had also flickering problem and a single line of code resolved my problem. Try this line in the Initilization of ure Control/Form : SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Change the first argument to ure needs. HTH. Hayder Marzouk