Problems with GetClientRect()
I am trying to use the GetClientRect() function to calculate the dimensions of a window. However, it doesn't seem to work and I don't know why. Following is a snippet of my code:
void CTestView::CreateCalendar()
{
RECT rect;
GetClientRect(&rect);
m_calendar.Create("Calendar Prog", WS_CHILD | WS_VISIBLE | WS_BORDER,
CRect(rect.left, rect.top, rect.right, rect.bottom),
this, IDC_CALENDAR);
}
As you can see I am trying to make the calendar occupy the full window.
Also can someone please tell me how to give an edit box focus. I am sure you use the SetFocus() function but I am unsure as to how to use it.
Thanks
Mark
Re: Problems with GetClientRect()
1/ I'm not sure this will be helpful for you but I dont know what exact is your problem.
To get the coord. of the full window call GetWindowRect(&rect).
2/
a) If you use Edit Box as a variable use SetFocus like this: SetFocus(m_MyEdit.m_hWnd)
b) If you use Edit Box as a control ID use SetFocus like this: SetFocus(GetDlgItem(IDC_MYEDIT))
Re: Problems with GetClientRect()
Seems like you aren't getting a reasonable value from
GetClientRect().
My suggestion is to set the size of your calendar ctrl
in OnSize() by using GetClientRect().
About SetFocus, read Alek's message!
Good luck. :)
Walter An