we are capturing the device context of the entire screen by means of GetDC():
and releasing it in the end, of course:Code:HDC hdc; hdc = GetDC(NULL);
we can write strings to the screen like this:Code:ReleaseDC(NULL, hdc);
this is very interesting, because we don't have to specify a window to draw on - it just draws above all windows. so, putting it in a WM_TIMER event and using GetCursorPos, we can have a label follow the cursor while it moves.Code:TextOut(hdc, 0, 0, "teste", 5);
now, here is the problem: this text can only be removed by invalidating the rect in which it was drawn - and there may be more than one HWND below the text, since this is the screen DC.
so, how to erase material drawn in the screen DC (i. e., without having to know in which HWND(s) it was drawn)? we have seen in the Internet techniques such as using FillRect(), but that won't work, because the screen DC is not necessarily "empty".
we could also do InvalidateRect() on every open HWND, but it doesn't seem the best way.
thank you in advance.
NOTE: we are learning GDI and Win32 API programming by ourselves, only with the help of the internet and with no book and no "formal" course. and we couldn't find a solution to this specific doubt anywhere else.