Re: Invalidate but do not draw background
From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 02/18/05
- Next message: Tim Wilson: "Re: BUG is in Combobox.Font ?"
- Previous message: B.J.: "Re: BUG is in Combobox.Font ?"
- In reply to: Viktor: "Invalidate but do not draw background"
- Next in thread: Viktor: "Re: Invalidate but do not draw background"
- Reply: Viktor: "Re: Invalidate but do not draw background"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Feb 2005 20:29:51 +0100
You can override the OnPaintBackground method to do nothing and always
handle bakground painting according to valid / invalid rects.
You can set the style AllPaintingInWmPaint which enables you to selectively
paint the background if you wish.
You should not paint anything using GetGraphics. This breaks the rules of
message-based architecture and causes problems. See the various entries in
the GDI+ FAQ for why.
-- Bob Powell [MVP] Visual C#, System.Drawing Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. "Viktor" <Viktor@discussions.microsoft.com> wrote in message news:ECBEAC26-56DD-482F-906A-3B975B1B4426@microsoft.com... >I work on a data acquisition system. I need to display data as it comes. > There are two different modes: 1. Display only current set of data each > time > it is ready. 2. Display the current data, but don't erase the previous > one. > I remember in MFC I was able to do this by changing one parameter > (DrawBackground() or something like that). I am trying to do it with C# > and > failing. > If I use Invalidate() or Invalidate(rect) functions, than the previous > data > is erased. However if I just use my plotting functions directly to display > the data, then I need to create Graphics (this.CreateGraphics) and pass it > to > the plotting routine. But then the program crashes some time when I try to > resize the window for example. It tells me that a Brush (or Color, etc...) > is > used somewhere. > > I think it is because I have two requests for plotting data with two > different Graphics: one is coming from acquisition board when the data is > ready, and the other - from Windows when I resize the window. > > Is there any way to use Invalidate() but somehow specify not to erase the > background? This would solve all the problems as I did not have to create > another Graphics and just use the one that is generated by .NET in the > Paint > message. > > Thank you in advance, > Viktor
- Next message: Tim Wilson: "Re: BUG is in Combobox.Font ?"
- Previous message: B.J.: "Re: BUG is in Combobox.Font ?"
- In reply to: Viktor: "Invalidate but do not draw background"
- Next in thread: Viktor: "Re: Invalidate but do not draw background"
- Reply: Viktor: "Re: Invalidate but do not draw background"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|