Advertisement

03.08.2005 at 11:01AM PST, ID: 21342513
[x]
Attachment Details

vc++, mdi, mfc, GetClientRect()

Asked by as2003 in Microsoft Visual C++.Net

Tags: failed, getclientrect, mfc, msdn

I have a child window, and I created a toolbar by using all the standard stuff. I also created an instance of a grid control.

I followed an example on msdn to make the toolbar work and it works fine but then when I then call GetClientRect to get the grid control to display in the right place, it ignores the tool bar and places the grid control on top of the tool bar.

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      if(CMDIChildWnd::OnCreate(lpCreateStruct)) return 1;

        if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
        {
           TRACE0("Failed to create toolbar\n");
           return -1;      // fail to create
        }

        // TODO: Remove this if you don't want tool tips or a
        // resizeable toolbar
        m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

        // TODO: Delete these three lines if you don't want the toolbar
        // to be dockable
        m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
        EnableDocking(CBRS_ALIGN_ANY);
        DockControlBar(&m_wndToolBar);

      CRect clientArea;
      GetClientRect(clientArea);
      //m_wndToolBar.GetWindowRect(toolbarArea); <-- I don't think this works
      clientArea.top += 30; //toolbarArea.Height();
      //AfxMessageBox("toolbarArea.Height()");
      m_gridDataDisplay.Create(clientArea, this, 1);
      m_gridDataDisplay.SetColumnCount(2);
      m_gridDataDisplay.SetRowCount(10);
      m_gridDataDisplay.SetAutoSizeStyle();
      return 0;
}Start Free Trial
[+][-]03.10.2005 at 12:48AM PST, ID: 13504000

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Tags: failed, getclientrect, mfc, msdn
Sign Up Now!
Solution Provided By: jaime_olivares
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.10.2005 at 05:43AM PST, ID: 13505711

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32