473,219 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

Odd GDI bug doublebuffering - Repost

Hi,

Re-posting this as the formatting on the other post is terrible.

If I inherit from a control with the following OnPaint override and draw in
the DoPaint method then i get odd UI results when a combobox is dropped down
on top of the control and then removed. I use this code in CE as well where
the problem is greater due to the loading circle and the volume control boxes
that pop-up.
This problem is reproducible on the desktop though. A full example is posted
afterwards for you to copy -paste and see the issue yourself.

Any help would be appreciated as the code looks fine to me (am I an idiot?)

protected override void OnPaint(PaintEventArgs e)
{
if (e.ClipRectangle.Width 0 && e.ClipRectangle.Height 0)
{
using (m_BackBuffer = new Bitmap(e.ClipRectangle.Width,
e.ClipRectangle.Height))
{
using (m_BackGraphics = Graphics.FromImage(m_BackBuffer))
{
DoPaint(new PaintEventArgs(m_BackGraphics, e.ClipRectangle));
}
e.Graphics.DrawImage(m_BackBuffer, 0, 0);
}
}
}

-------

Full example: http://www.nomorepasting.com/getpaste.php?pasteid=16435
(posted elsewhere to prevent the replies from getting too long)
Jun 27 '08 #1
4 1175
Oh I should add that as this is CE code aimed at the Compact Framework 2.00,
SetStyles() isn't available to me as it isn't supported in CF 2.00. :'(
Jun 27 '08 #2
On Tue, 03 Jun 2008 11:16:00 -0700, Simon Tamman
<Si*********@discussions.microsoft.comwrote:
If I inherit from a control with the following OnPaint override and draw
in
the DoPaint method then i get odd UI results when a combobox is dropped
down
on top of the control and then removed.
This is almost certainly due to your incorrect use of ClipRectangle. See
my other reply for more details.
Jun 27 '08 #3
The cliprect can be anywhere in the middle of the drawing area. This code
assumes that it always starts in the upper left hand corner. It is probably
easiest to always make the back buffer be the size of the control's window
rect and then just grab the clip-rect portion after rendering. Or you can
try an put more effort into setting up the Bitmap's DC's offsets so that
bitmap is positioned within the cliprect for the control. (But you can't
always control what happens for 'off-screen' drawing and just a little
coordinate wrapping can really mess things up)

I did something similar 17 years ago and remember having a particularly
difficult time getting this to work for combo-boxes, maybe something about
having a hard time identifying the actual window containing the drop down?
Good luck.

"Simon Tamman" wrote:
Hi,

Re-posting this as the formatting on the other post is terrible.

If I inherit from a control with the following OnPaint override and draw in
the DoPaint method then i get odd UI results when a combobox is dropped down
on top of the control and then removed. I use this code in CE as well where
the problem is greater due to the loading circle and the volume control boxes
that pop-up.
This problem is reproducible on the desktop though. A full example is posted
afterwards for you to copy -paste and see the issue yourself.

Any help would be appreciated as the code looks fine to me (am I an idiot?)

protected override void OnPaint(PaintEventArgs e)
{
if (e.ClipRectangle.Width 0 && e.ClipRectangle.Height 0)
{
using (m_BackBuffer = new Bitmap(e.ClipRectangle.Width,
e.ClipRectangle.Height))
{
using (m_BackGraphics = Graphics.FromImage(m_BackBuffer))
{
DoPaint(new PaintEventArgs(m_BackGraphics, e.ClipRectangle));
}
e.Graphics.DrawImage(m_BackBuffer, 0, 0);
}
}
}

-------

Full example: http://www.nomorepasting.com/getpaste.php?pasteid=16435
(posted elsewhere to prevent the replies from getting too long)
Jun 27 '08 #4
Thank you so much Peter! :)
Have responded in the other thread:

http://www.microsoft.com/communities...2fsettings.xml
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Adam | last post by:
I've posted about this previously, but failed to receive a satisfactory response, so have included a code sample: I am trying to receive messages from an HTML viewer control in compact.net (c#),...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
5
by: Adrian Parker | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
2
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the...
2
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.