Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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 …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

578 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