So then, how exactly would I go about using it? Get the device context and simply draw using that? Don't I have to invalidate the rect containing the area too?
Sorry, I lost interest in the WinAPI after figuring out that it would be much faster to simply use DirectX (which should've been obvious from the beginning >.>), and so I don't know much about using pens. How exactly would I get the currently used pen?
I lost interest in WinAPI as soon as I found wx. This stuff is just from memory.
Anyway... I don't remember exactly how to create a pen and am too lazy to look it up, so I'll do this with a stock brush instead (that way there's less cleanup, too)
Plus -- it dawns on me that your RECT is wrong (it has a width and height of 0, so you're basically invalidating nothing).
Anyway here's my code that fills a 100x100 square with solid black. This ought to work:
1 2 3 4 5 6 7 8 9 10 11 12 13
RECT rect;
rect.top = 200;
rect.left = 200;
rect.right = 300;
rect.bottom = 300;
HDC hdc = GetDC ( hwnd );
HBRUSH br = (HBRUSH)GetStockObject(BLACK_BRUSH);
FillRect(hdc,&rect,br);
ReleaseDC(hwnd,hdc);
InvalidateRect(hwnd,&rect,true); // I don't think this is necessary, actually
Another problem might have been that you were invalidating the rect before you released the DC (and you weren't releasing the DC until after that massive loop). Keep in mind that the Desktop needs to get the DC to draw, which it can't do if your program takes it and holds onto it for extended periods of time.
I think the desktop window is a two part window - the bit with the icons (which is the part you are after) is a childwindow of the desktop (window) or something like that.