Sign in to follow this  
Luth

Drawing outside of a window

Recommended Posts

Luth    130
Wasn't sure if this should go under Graphics or what, but its here, so I guess we can just deal with it. :) There are a variety of little programs that draw sprites to the screen outside of a window. Most have some avatar or character that follow the mouse cursor or sit on the desktop and spam you. You know the kinds I'm talking about, I'm sure. Mouse clicks and keyboard events go right through to the desktop or the active window. I was just wondering how to go about doing that. I want to make a little avatar that bounces around the desktop (or, ideally, on top of all windows) until you stop running the program. Any help would be appreciated. Any c++ code examples would be rewarded with... um... virtual beer? Thanks.

Share this post


Link to post
Share on other sites
Luth    130
Thanks. That helped a lot for drawing to the desktop.

What about drawing on top of everything? Any resources for something like that? I haven't done a lot of in-windows manipulating. :)

PS: IOU 1 VB

Share this post


Link to post
Share on other sites
Anon Mike    1098
Drawing on the desktop is really a big no-no. It'll work (mostly) but it's definitely not recommended. Especially on Vista where it's likely to be *much* slower than on previous versions of Windows because the new window manager / compositor runs on top of DX and you can't really get directly at the desktop bits in the same way you can with GDI where you're talking more or less directly to the frame buffer.

The friendlier way to draw "outside of a window" is to draw inside of a window that doesn't have all the usual window decorations (borders, title bars, etc). The Windowsese you need is "layered windows". You also get always on top behavior for free by setting the always on top property of the window.

Share this post


Link to post
Share on other sites
Luth    130
But that wont give me the effect of running graphics beneath icons, and such, will it? And what about passing through any mouse or keyboard events that actually fall in the Layered Window (even though at 0% opacity, it doesnt look like it) and should actually pass through to whatever window is beneath it?

------

Edit: Before I start making my top-always version (which I probably will use the layered windows as per your advice), I want to try to perfect my desktop version. I'm having trouble integrating D3D sprites with the desktop rendering method. So far, I -do- have it rendering D3D to the desktop, but its far from perfect. Here's my current chain of events:


m_pD3D->BeginFrame(); // Clears the back buffer too
m_pSprite->Draw();
m_pD3D->EndFrame();
RedrawWindow( m_hDesktopWnd, NULL, NULL, RDW_NOERASE | RDW_INVALIDATE);
m_pD3D->Present();



Two problems:
1) The desktop wallpaper disappears (or rather, is completely cleared by the D3D Clear Screen and doesn't redraw).
2) The icons flicker.

I don't know why the wallpaper disappears. Any hints on that would be great. I know why the icons flicker; I just don't know enough to fix it. Its because I'm drawing the D3D Buffer and then drawing the icons on top of it. I know you can get the DC of the D3D back buffer surface, but I don't know how to get the icon information from the DesktopWnd/DC to the back buffer so that it can all be presented at once instead of on two passes.

[Edited by - Luth on March 21, 2007 2:33:59 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this