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

Posted on 2003-03-15
Medium Priority
Last Modified: 2008-01-09
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!
Question by:wearyweary
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8144144
You can use GetDC(NULL);
to retrieve the Device Context for the Screen in your
Paint handler.  Then do your drawing to that DC.

Author Comment

ID: 8145022
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?

Expert Comment

ID: 8150928
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.
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.


Author Comment

ID: 8152386

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?


Accepted Solution

ChrisSeaton earned 75 total points
ID: 8169183
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.

Expert Comment

ID: 8177733
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.

Author Comment

ID: 8177909

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.


Expert Comment

ID: 8177930
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...

Expert Comment

ID: 8221513
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.

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question