int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
//这里大小为什么是0000?
//而且,我改成其他任何数字,都没有反应,怎么回事?
{
TRACE0("Failed to create view window\n");
return -1;
}

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1;      // fail to create
} if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
  sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;      // fail to create
} // 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); return 0;
}

解决方案 »

  1.   

    因为你的风格设置的是默认视图风格AFX_WS_DEFAULT_VIEW
    下面是这个风格的定义
    #define AFX_WS_DEFAULT_VIEW  (WS_CHILD | WS_VISIBLE | WS_BORDER)无论你怎么改变CRect的值,默认的视图都会从坐标0,0开始,填充整个框架窗口!
      

  2.   

    视图创建时为大小和位置为0,但当Onsize时会设置为和外框窗口一样的size大小
      

  3.   

    to yongdu() :
    你说的OnSize,是谁的OnSize呢?是CMainFrame的吗?