HWND for the desktop?

Anyone know a way to retreive the desktops hwnd? I want to be able to draw a calendar in the bottom right corner. So I guess I really need a cdc for it, but I can just get that thru the hwnd.

I've been looking everywhere and I cant find any info on it. I found a program (Z-Matrix) which edits the desktop so I know its possible..

Any help would be MUCH appreciated.
Who is Participating?
MrNoNameConnect With a Mentor Commented:
Hi DigitalQ,

You can obtain a device context to the desktop like this:

CWindowDC dc (0);
DigitalQAuthor Commented:
Thx, I honestly dont know why I didnt think of that.. I'm sure I've used CWindowsDC before..

I appreciate a quick response
HWND GetDesktopWindow();

DigitalQAuthor Commented:
Yes but it seems like any dc I try to make from that doesnt allow me to do anything. Maybe the background picture is always painted last? Anyway around that?
>>Maybe the background picture is always painted last
Try with LockWindowUpdate().
Inside Charles Petzold book ( Window programming ) there 's a scramble example using desktop dc
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.

All Courses

From novice to tech pro — start learning today.