Remember when using GDI objects (pens, brushes, DC ect) that they are special memory. If you do not free the memory it will crash your PC.
If you 'Get' an object 'Release' it.
If you 'Create' an object 'Delete' it.
Always catch the returned GDI object from SelectObject() to replace them later.
roughly
Code:
#define BLACK RGB(0,0,0)
#define WHITE RGB(255,255,255)
hdc=GetDC(hWnd);// get the DC to draw on and create the objects to draw with
hdPen=CreatePen(PS_SOLID,iLineThickness,BLACK);
hBrush=CreateSolidBrush(WHITE);
GetClientRect(hWnd,&ClientRect);
hOriginalPen=(HPEN)SelectObject(hdc,hPen);//catch the pen already in the DC
//do the drawing
FrameRect(hdc,&ClientRect,hBrush);
//clean up by putting the DC back the way we got it
SelectObject(hdc,hOriginalPen);
//then delete the pen
DeleteObject(hPen);
//the brush was not in a DC so can just delete
DeleteObject(hBrush);
//the DC was 'Get'ed so 'Release' it
ReleaseDC(hWnd,hdc);