Re: Invalidate but do not draw background

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 02/18/05


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 


Relevant Pages

  • How to display selection handles
    ... but heretofore have not had the requirement to display graphics in a ... The standard Windows procedure to to left click the graphic and have the ... graphic highlighted via display of the familar selection rectangles. ...
    (microsoft.public.vc.mfc)
  • RE: PowerPoint Display Issue
    ... Try notching back graphics accelleration (Sorry if this is a double post my ... Windows version:OS Name Microsoft Windows XP Professional ... .jpg photos do not display in the normal view window ... when selecting a slide layout, I notice that the dotted lines that normally ...
    (microsoft.public.powerpoint)
  • Re: Wierd computer design...
    ... > I need a little hardware guidance from the experts. ... If you need to display relatively "static" information (ex: ... If Windows CE cannot handle so many displays (and if Steve Maillet ... you don't need fast graphics. ...
    (microsoft.public.windowsce.platbuilder)
  • need book materials
    ... SUMMARY: DISPLAY issue ... Netbackup 6.5 with Solaris 2.6 and 7 clients ... Subject: Windows permission for Samba ... Pos Port_ID Hard_Addr Port WWN Node WWN Type ...
    (SunManagers)
  • Re: Name change
    ... windows - you just don't have the room for anything else if you ask me. ... You can do a lot with an 80x25 character display. ... icon for each window (either globally or on just the current virtual ... I'd say it's the CPU itself (or one ...
    (uk.people.support.depression)