Click to See Complete Forum and Search --> : Please help to clear text, which I draw over the desktop


vfil
October 18th, 2004, 03:28 AM
I am drawing text over the desktop like this:

HDC hDC;
hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
if (hDC)
{
SetBkMode(hDC, TRANSPARENT);
TextOut(hDC, GetSystemMetrics(SM_CXSCREEN) / 2, GetSystemMetrics(SM_CYSCREEN) / 2, "Hello world!", 12);
}
DeleteDC(hDC);

This text removes when some window overlap the desktop.
Can somebody tell me how programatically clear my text from the desktop?

kirants
October 18th, 2004, 07:46 PM
A desktop is a window. The text is cleared when you move a window over it is because, the desktop window will receive a WM_PAINT message and in it's handler , it's gonna do the painting of itself. Now, since the desktop window has no knowledge of what you are painting on it, it is not gonna do the part of drawing your text. Hence, you see it getting wiped out.

Part 2 of your question:
Can somebody tell me how programatically clear my text from the desktop?
You can by doing an InvalidateWindow() followed by UpdateWindow() on the desktop window handle ( use GetDesktopWindow() ). Again, this is going to invalidate the window for the next paint and UpdateWindow() is going to trigger the next paint.