16,472
社区成员
发帖
与我相关
我的任务
分享
UINT TargetCtrlID = IDC_RESULT_STATIC;
CWnd *pWnd = this->GetDlgItem(TargetCtrlID);
CRect RectTargetCtrl;
pWnd->GetWindowRect(RectTargetCtrl);
m_pFrame = (CFrameWnd*)pWnd;
m_resultView = new CResultView();
m_resultView = (CResultView*) RUNTIME_CLASS(CResultView)->CreateObject();
CCreateContext context;
context.m_pCurrentFrame = m_pFrame;
context.m_pLastView = m_resultView;
context.m_pNewDocTemplate = NULL;
context.m_pNewViewClass = NULL;
m_resultView->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,RectTargetCtrl,m_pFrame,TargetCtrlID,&context);
m_resultView->CenterWindow();
//m_resultView->SetScrollSizes(MM_TEXT,CSize(RectTargetCtrl.Width(),RectTargetCtrl.Height()));
m_resultView->OnInitialUpdate();
return TRUE;
CResultview中只有 OnInitialUpdate()修改了一下,其它都是自动生成,修改代码如下:
void CResultView::OnInitialUpdate()
{
//CView::OnInitialUpdate();
CZoomView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 1500;
// Initialize the CZoomView class
SetZoomSizes(sizeTotal);
//SetScrollSizes(MM_TEXT,sizeTotal);
}
然后报错, 因为要在视图上使用onDraw绘制图像的时候需要先调用这个OnInitialUpdate来初始化, 程序运行直接报错, 提示没有调用这个函数, 单步跟踪 发现它直接同viewcore.cpp执行了OnInitialUpdate就走了,再也没回来执行下面的语句了