Drawing "on top of" the desktop (what to use? overlay?)

Hey Guys,

I'm looking for a means to do the following.  I need to create a layer infront the windows desktop in which I can draw over top of the desktop, and have it stay there, not interfering any apps below. It has to cover top most windows and everything.

I would really like to find a way of doing this that uses the video card rather than CPU time. The first thing I tried was creating a full screen regular window, and using a tranparency:

SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(RGB(255,0,255),255, LWA_COLORKEY | LWA_ALPHA);

This sort of works, but it seems pretty slow, and other Top Most windows will cover it if they are clicked. I would also like clicks to go "through" the drawing, which they obviously don't.

I'm looking for other ways that I can do this. Is it possible to do this with DirectDraw somehow? It would be great if I could create a surface that is mostly trasparent, but covers the whole desktop.

Thanks in advance!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use GetDC(NULL);
to retrieve the Device Context for the Screen in your
Paint handler.  Then do your drawing to that DC.
wearywearyAuthor Commented:
I don't think that helps. When windows redraw themselves, won't it cover what I have drawn?  How can I keep what I have drawn perminantly on top this way?
If you wan't that Windows's windows ;-) are drawn normally (animated, moved...) at the same time, you have to redraw your front-layer every time the normal desktop rePaints.

It would be different case if desktop should not update when your App is on.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

wearywearyAuthor Commented:

Using my method above, I didn't have to redraw my window every time any other window is updated. However, it seems slow, due to windows having to mask everything that was drawn under it.

I think the problem with using the Desktop's DC, is that should I want to move what I have drawn, I will need to both tell the desktop to repaint, and then repaint my drawing.

That said, how can I know when the desktop has repainted?

Does DirectDraw not support some kind of overlay I can use that would be similar to my method, only hardware accelerated?

You can't have a layered hardware layer, because it would have to work with the software layers (normal windows) which is impossible. This is why the cursor shadow in 2000 and XP screws up on a hardware layer.

I think you'll have to use a software layered window. You can make a layer transparent to mouse events (they go through to the layer below) by setting WS_EX_TRANSPARENT.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
With DirectX DirectDraw (DX7) in windowed mode, you draw on the full screen.  Normally this is a problem and you need to use a clipper to keep from overdrawing everything else, but perhaps you actually want to do that?

Now as for updates from behind what you draw, that would take more work.
wearywearyAuthor Commented:

Yeah, I'm currently using a fullscreen window with WS_EX_LAYERED and  WS_EX_TRANSPARENT with a transparecy key.

It works sort of decent, but other topmost windows cover it.  I could likely "unTopMost" them, but then their order gets messed up.

Any ideas in this regard?

Would it be possible to use DirectDraw to draw into my window? or would this destroy the transparent parts.

So you're not using DirectDraw right now then I'm assuming.
Using DirectDraw you will always be able to draw on top of anything else, so you won't have to worry about programs being "on top of you".  Also my point was that your window does not have to be a fullscreen window, you have control to draw over the whole SCREEN now just where your window is.

Not for sure what you're trying to do though...
It sounds like he wants to do something similar to that old sheep game and similar. Where a sheep ran around the screen and u shot it.

I'd say DD in windowed mode with no clipper. I'm not sure about refreshing, u may have to hook into WM_PAINT events for other apps and re-draw ur frame.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.