SelectObject: If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
rusite tedy ten puvodni handle, ktery je nejspis nejaky systemovy.
void KresliKostku (int x, int y, int ink)
{
hPen=CreatePen(PS_SOLID | PS_INSIDEFRAME,1, ink);
hOldPen = (HPEN) SelectObject (hdcMem, hPen);
GetClientRect(hWnd, &block);
Rectangle(hdcMem, x,y,x+4,y+4);
SelectObject(hdcMem,hOldPen);
DeleteObject(hPen);
}