OnCreate( _ ) method of a window class object used to reaponse the WM_CREATE. At the mean time, the window has just created but not shown yet. That's why the call to method GetWindowRect ( _ ) can get nothing.

There are many way to correct this problem. One can be the following:

In OnCreate( _ ) method:

// some things done

// then we create the static object
m_wndStatic.Create("test",
WS_CHILD | WS_VISIBLE | SS_GRAYRECT,
CRect(0,0,10,10), this);

return 0;


In the method OnSize(UINT nType, int cx, int cy) , stretch the child window m_wndStatic face to fix the parent's size:

CWnd ::OnSize(nType, cx, cy);

m_wndStatic.MoveWindow(0, 0, cx, cy);