-
CStatic and View
I have a CView which is one of three views that is seperated by
SplitterWnds. In this view i would like to create a CStatic
object which is in the entire size of the view. I would also like
it resize when the splitter is moved (thus resizing the view).
In the OnCreate function of my View i have the following
Code:
CRect rect;
this->GetClientRect(&rect);
m_wndStatic.Create("test", WS_CHILD | WS_VISIBLE | SS_GRAYRECT, rect, this, IDC_STATIC0;
the create call fails (returns a 1).
if i deflate the rect by say -10 units for each parameter (top, left,
right, and bottom) a very small static object shows.
What am i doing wrong? why is the call to GetClientRect not
filling the CRect object?
any help would be greatly appreciated.
thank you
-
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);
-
where can i put the creation of the static control then?
i have it after my view calls the base class' OnCreate
so it should be a window then?
-
-
i' mhaving difficutly centering the static frame within the view
-
Uhhh
CStatic::Create returns BOOL, where TRUE is defined as 1...
This means it doesn't fail...