您的位置:首页 > 其它

mfc中dialog中嵌入view

2012-10-09 10:15 134 查看
在dialog::OnInitDialog中加入

CWnd* pFrameWnd = this;

CCreateContext pContext;

pContext.m_pCurrentDoc = 0;//new CTest_simpleDoc;

pContext.m_pNewViewClass = RUNTIME_CLASS(C2); //C2view类

C2* pView = (C2*)((CFrameWnd*)pFrameWnd)->CreateView(&pContext);

pView->ShowWindow(SW_NORMAL);

CRect rectWindow;

GetClientRect(&rectWindow);

pView->MoveWindow(rectWindow);

CSize sizeTotal;

sizeTotal.cx = sizeTotal.cy = 1000;

pView->SetScrollSizes(MM_TEXT, sizeTotal);

类似的代码。

再在CView派生类里面处理下面消息

int C2::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)

{

return MA_ACTIVATE;//CScrollView::OnMouseActivate(pDesktopWnd,nHitTest, message);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: