在CFormView派生的CXXView里,响应WM_SIZE,代码如下void CEDView::OnSize(UINT nType, int cx, int cy) 
{
CFormView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
CRect clientRect;
GetClientRect(&clientRect);
int iBound = clientRect.right*2/3;//客户区的左边的三分之二作为规格编辑区 CRect specRect;
specRect.bottom = clientRect.bottom - 10;
specRect.top = clientRect.top + 10;
specRect.left = clientRect.left + 10;
specRect.right = iBound - 10;
GetDlgItem(IDC_SPECLIST)->MoveWindow(clientRect.top,clientRect.left,
clientRect.right-clientRect.left,clientRect.bottom-clientRect.top,true);
}IDC_SPECLIST是一个标识框的ID,,试过换成CListCtrl的ID也不行,调试时跟进去是CWnd::MoveWindow里的ASSERT(::IsWindow(m_hWnd))出现断言啦,怎么解决?谢谢各位大侠...
急,在线等,,,,

解决方案 »

  1.   

    初始的时候,窗口上的子窗口还没有真正建立,这时必须进行相关校验。如下:
    if(GetDlgItem(IDC_SPECLIST)->GetSafeHwnd())
        GetDlgItem(IDC_SPECLIST)->MoveWindow(clientRect.top,clientRect.left,
    clientRect.right-clientRect.left,clientRect.bottom-clientRect.top,true);
      

  2.   

    同意楼上.第一次时OnSize中控件句柄为空
      

  3.   

    同意,窗口在还没建好时调用movewindow(),则出错