//当前存在之前的地方派生
CWnd *pCWnd = AfxGetMainWnd();//
CMainFrame *pCMainFrame = (CMainFrame*)pCWnd;//获得主窗体
CMDIChildWnd *pMDIChildWnd = pCMainFrame->MDIGetActive();//获得主窗体中的活动窗口
CDocument *pDocument =pMDIChildWnd->GetActiveDocument();//获得活动的工作区
POSITION pPosition= pDocument->GetFirstViewPosition();//获得活动区第一个视图的位置
CView* pView = pDocument->GetNextView(pPosition);//根据当前视图获得下一视图
pView->IsKindOf(RUNTIME_CLASS(CWebView));//往子类拓展true 拓展成功 false拓展失败
CWebView* pWebView= (CWebView*)pView;
CFrameWnd *pFrameWnd= pView->GetParentFrame();//获得主创就
pFrameWnd->IsKindOf(RUNTIME_CLASS(CChildFrame));
//在新的模板中创建
CWinApp *pWinApp= AfxGetApp();//获得App
CTestApp *pDYBApp =(CTestApp*)pWinApp;//转换成子类
CDocTemplate* pTemplate= pDYBApp->m_pDocTemplateWeb;//获得子类中的Doc模板
ASSERT_VALID(pTemplate); //判定pTemplate可用
CFrameWnd *pFrame= pTemplate->CreateNewFrame(pDocument,pMDIChildWnd);//创建窗体,
pTemplate->InitialUpdateFrame(pFrame, pDocument); //设置当前pFrame为活动视图
CView *pCView2 = pFrame->GetActiveView();
CWebView* pWebView= dynamic_cast<CWebView*>(pCView2);//强制转换,地址不偏移
pWebView->Navigate2(_T("www.baidu.com"),NULL,NULL);
【框架-MFC】CHtmlView(chenlu-1):将网页嵌入MFC的视图中
最新推荐文章于 2023-04-01 16:31:05 发布