本人作了一个分割的单文档程序,左边为TreeView,右边上面和下面都是一个FormView,上面的FormView中放置了一个msflexgrid控件,我用以下的方法使它随CFormView的大小而变化,也就是充满整个View:
void CXXXXView::OnSize(UINT nType, int cx, int cy) 
{
CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here

// Get safe handle
if(! AfxGetApp()->m_pMainWnd->GetSafeHwnd())
{
return;
} m_grid.SetWindowPos(this,0,0,cx,cy,false);
}
这样没问题,同样的处理我用在下面的FormView时却出了问题:
void CYYYView::OnSize(UINT nType, int cx, int cy) 
{
CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here // Get safe handle
if(! AfxGetApp()->m_pMainWnd->GetSafeHwnd())
{
return;
}

RECT rect;
rect.top=cy;
rect.left=0;
rect.bottom=cy;
rect.right=cx;
m_edit.MoveWindow(&rect);//m_edit是一个RichEdit控件,我已经在App的InitInstance中加入了AfxInitRichEdit();一句
}我用调试模式编译时,程序指出m_edit.MoveWindow(&rect);这句发生了错误,错误提示是:
The thread 0x4E8 has exited with code 3 (0x3).
The program 'H:\PROG\VC\VIEW\WkSchedule\Debug\WkSchedule.exe' has exited with code 3 (0x3).请问大家这是什么原因,该怎么解决,谢谢。

解决方案 »

  1.   

    RECT rect;
    rect.top=cy;
    rect.left=0;
    rect.bottom=cy;
    rect.right=cx;怎么top和bottom都等于cy,那还是矩形吗?
      

  2.   

    不好意思,现在这样还是有错啊。
    RECT rect;
    rect.top=0;
    rect.left=0;
    rect.bottom=cy;
    rect.right=cx;

    m_edit.MoveWindow(&rect);
      

  3.   

    是出错了退出,还是直接退出了,看代码好像没问题了
    要不rebuild all试一试
      

  4.   

    你改成:
    if( m_edit.GetSafeHwnd() )
    {
             RECT rect;
    rect.top=0;
    rect.left=0;
    rect.bottom=cy;
    rect.right=cx;

    m_edit.MoveWindow(&rect);
    }试试
      

  5.   

    to : szclm(IT的民工) :
       好用了,感谢。能说一下原因吗?