Reputation: 31
How Would I go about placing text on the windows desktop? I've been told that GetDesktopWindow() is what I need but I need an example.
Upvotes: 3
Views: 5202
Reputation: 956
If your intent is to produce something like the Sidebar, you probably just want to create one or more layered windows. That will also allow you to process mouse clicks and other normal sources of input, and if you supply the alpha channel information, Windows will make sure that your window is drawn properly at all times. If you don't want the window to be interactive, use appropriate styles (such as WS_EX_NOACTIVATE) like Koro suggests.
Upvotes: 0
Reputation: 6258
i haven't tried but i assume you could do the following:
not 100% sure it will work, but seems like it should as this is the normal way to subclass a window.
-don
Upvotes: 0
Reputation: 4834
Why not just draw the text in the desktop wallpaper image file?
This solution would be feasible if you don't have to update the information too often and if you have a wallpaper image.
One can easily use CImage class to load the wallpaper image, CImage::GetDC() to obtain a device context to draw into, then save the new image, and finally update the desktop wallpaper to the new image.
Upvotes: 1
Reputation: 697
I'm assuming your ultimate goal is displaying some sort of status information on the desktop.
You will have to do either:
Inject a DLL into Explorer's process and subclass the desktop window (the SysListView32
at the bottom of the Progman
window's hierarchy) to paint your text directly onto it.
Create a nonactivatable window whose background is painted using PaintDesktop
and paint your text on it.
First solution is the most intrusive, and quite hard to code, so I would not recommend it.
Second solution allows the most flexibility. No "undocumented" or reliance on a specific implementation of Explorer, or even of just having Explorer as a shell.
In order to prevent a window from being brought to the top when clicked, you can use the extended window style WS_EX_NOACTIVATE
on Windows 2000 and up. On downlevel systems, you can handle the WM_MOUSEACTIVATE
message and return MA_NOACTIVATE
.
You can get away with the PaintDesktop
call if you need true transparency by using layered windows, but the concept stays the same. I wrote another answer detailing how to properly do layered windows with alpha using GDI+.
Upvotes: 9