473,395 Members | 1,679 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,395 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 1179
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.