在对话框中使用CSrollView
来源:互联网 发布:ipadmini安装不了软件 编辑:程序博客网 时间:2024/06/18 12:20
BOOL CViewDlgDemoDlg::OnInitDialog(){ CDialog::OnInitDialog(); CRect rectWindow; GetWindowRect(rectWindow); CRuntimeClass *pViewClass = RUNTIME_CLASS(CMyScrollView); CCreateContext * pContext; pContext = new CCreateContext; pContext->m_pCurrentDoc = NULL; pContext->m_pCurrentFrame = NULL; pContext->m_pLastView = NULL; pContext->m_pNewDocTemplate =NULL; pContext->m_pNewViewClass = pViewClass; CWnd * pWnd = NULL; pWnd = DYNAMIC_DOWNCAST(CWnd,pViewClass->CreateObject()); pWnd->reate(NULL,NULL,AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0),this,0,pContext); delete pContext; CMyScrollView * pScollView = DYNAMIC_DOWNCAST(CMyScrollView,pWnd); pScollView->SetScrollSizes( MM_TEXT, CSize(rectWindow.right - rectWindow.left-20, rectWindow.bottom -rectWindow.top-100) ); pScollView->MoveWindow(rectWindow.left,rectWindow.top,rectWindow.right - rectWindow.left-20, rectWindow.bottom -rectWindow.top-100,TRUE); return true;}