Drawing at highest z-layer???

J

Jason

Hi --

I have a very simple question, the answer of which has eluded me for
quite some time: How can I draw at the topmost layer of forms and
controls from .NET (or from unmanaged code, that would be fine too)??

Any GDI+ drawing I've done only appears on the background of the
form/control/whatever. Anything contained by the, say, form, draws
over the custom GDI+ drawing. Now, let's say I wanted to do something
like the translucent rubber-band select in Win XP explorer: anyone
have any idea how that might be done???

Many thanks in advance,
Jason
 
B

Bob Powell [MVP]

There are no "Z" layers in GDI+ except that provided by the good old
painters algorithm. Objects that appear to be on top of others are simply
drawn last.

The surfaces of controls are clipped by the window extents so if your
question is how to draw outside of that clipped area then you must obtain
the desktop window handle and draw upon that.

Like all graphics in GDI+ or indeed GDI, this process is a destructive one
and the system does not retain any information about what was there before,
it can only get windows to redraw themselves again. Therefore if you wan to
un-draw you must have made a copy of what was there in the first place
before you mucked it up with whatever you drew.

--
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.
 
J

Josh Ross

I have a function that takes a handle, location and size and returns an
image.
So how do I get the obtain the desktop window handle?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top