CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    5

    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


  2. #2
    Join Date
    Apr 1999
    Posts
    24

    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))



  3. #3
    Join Date
    May 1999
    Location
    Republic of Korea
    Posts
    100

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured