Re: How to draw to the screen not the form?

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




Yes, that function does the same (although one is limited
to two styles then).

But the thing is: It still obtains/releases a handle to the
desktop DC under the covers. I understood from the article
I linked to in my previous post
(http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx)
that you should avoid writing to/reading from the screen (at
least for something as realtime as this, though a screen capture
program would be ok)?

I have a component where I currently draw some selection
rectangles directly on the screen (which is similar in nature to
what the original poster is attempting). Trouble is: When I run
this on Vista with Aero enabled, dragging those rectangles around
happen at a few frames a second, whereas it runs smooth
on XP (or Vista with the standard, non-Aero theme).

Wouldn't the original poster have the same problem if using
ControlPaint.DrawReversible...?

I have considered solving my own problem this way:

1. On MouseDown, grab a snapshot containing the portion of the screen
my interface occupies. Only one desktop GetDC required.

2. Put this snapshot on an overlay and display this on top of my
interface.

3. On MouseMove, draw my rectangles on the overlay.

4. On MouseUp, remove the overlay.

This would make the rectangles part of my application and would
not constantly force Vista in and out of DirectX10.

I am not convinced that ControlPaint.DrawReversible...
is as appropriate today as it has been in the past. Also remember that
this method *only* draws on the desktop. If you need to draw such
rectangles on other device contexts, you have to implement it
yourself.

Any thoughts?

/Joergen Bech



On Thu, 26 Oct 2006 12:52:19 +0200, "Bob Powell [MVP]"
<bob@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Just use ControlPaint.DrawReversiblexxx. That draws directly on the desktop
and can draw outside of windows etc.

.



Relevant Pages

  • Re: How to draw to the screen not the form?
    ... I hadn't considered the Vista implications. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... this on Vista with Aero enabled, dragging those rectangles around ... draw my rectangles on the overlay. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Draw Rectangle directly to client (ie - without bitmap?)
    ... Perhaps you should draw your rectangles to an image in memory and then ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Unusable outer edge of Tkinter canvases?
    ... > When drawing rectangles in Tkinter canvases I've noticed the outer edges ... > don't always draw. ... inner border. ... to the widget (this fixes the coordinate system), ...
    (comp.lang.python)
  • Re: Having trouble with pens and brushes
    ... it seems you drawed the rectangles in the OnMouseUp ... If you draw in this method, ... WM_PAINT message will invoke PaintHandler again, ... rectangle drawing, so you will not see the rectangle. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: C#) How to keep drawing graphics by GDI
    ... But this also impossible because the drawing data is too much to keep ... When the Paint event handler is called, draw ... user control is draw only last one because Paint event ... I need all rectangles, so I draw on other function not paint event. ...
    (microsoft.public.dotnet.languages.csharp)