|
In SDI, spiltter into two parts, top is a formview and bottom is a framewnd, the framewnd only has a tabview, I want to dynacially create a htmlview in the tabview, but can not show anything, below is the code, Who can help me.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { SIZE size1; CRect rect; GetClientRect(&rect);
size1.cx = rect.right/2 ; size1.cy = rect.bottom/2;
m_wndSplit.CreateStatic(this, 2,1,WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, AFX_IDW_PANE_FIRST ); m_wndSplit.CreateView(0,0,RUNTIME_CLASS(CMyFormView), size1, pContext);
// Create the view using a CFrameWnd derived class. m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CMyFrameWndBar), size1, pContext);
m_wndSplit.RecalcLayout(); RecalcLayout(); return TRUE; }
//CMyFrameWndBar : public CXTFrameWnd BOOL CMyFrameWndBar::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) {
pContext->m_pNewViewClass = RUNTIME_CLASS(CMyTabView); m_MyTabView = (CMyTabView *) CreateView(pContext, AFX_IDW_PANE_FIRST);
if (m_MyTabView == NULL) return FALSE;
return CXTFrameWnd::OnCreateClient(lpcs, pContext); }
//class CMyTabView : public CXTTabView int CMyTabView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTTabView::OnCreate(lpCreateStruct) == -1) return -1; /* //if add below code, if i add Navigate when active, error happen. CRuntimeClass *pNewViewClass1 = RUNTIME_CLASS(CMyWebView); CRuntimeClass *pNewViewClass2 = RUNTIME_CLASS(CMyWebView); AddView("Wicked Code",pNewViewClass1,NULL,NULL,-1,-1); AddView("Creating Sophisticated Tabbed",pNewViewClass2,NULL,NULL,-1,-1); GetTabCtrl().SetMinTabWidth(64); GetTabCtrl().ModifyStyleEx(WS_EX_CLIENTEDGE,0,0); SetActiveView(1); */ //
return 1; //0 }
class CMyWebView : public CHtmlView
//I want to dynacially create a htmlview in the tabview, but can not show. void CMainFrame::OnDynNewHtmlView() { // TODO: Add your command handler code here
CCreateContext createContext;
pNewViewClass3 = RUNTIME_CLASS(CMyWebView); // createContext.m_pNewViewClass = pNewViewClass3; createContext.m_pCurrentDoc = NULL; //createContext.m_pCurrentDoc = MyFrameWndBar->GetActiveDocument();
createContext.m_pNewDocTemplate = NULL; // // CMyWebView* pNewView = MyFrameWndBar->m_MyTabView->CreateTabView(pNewViewClas s3, NULL, &createContext); int nReturn=(MyFrameWndBar->m_MyTabView)->AddView("test",p NewViewClass3,NULL,&createContext,-1,-1); (MyFrameWndBar->m_MyTabView)->SetActiveView(2); // m_wndSplit.RecalcLayout(); // RecalcLayout(); m_listViews.AddTail((CView*)pNewViewClass3); }
|