在我的一个MDI 程序ReManage中, 定义了几个从CFormView派生的视图:CNoOneParaView,CNoTwoParaView ...;初始化视图为:CNoOneParaView
BOOL CReManageApp::InitInstance() CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_RELAYMTYPE,
RUNTIME_CLASS(CReManageDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CNoOneParaView));//初始化的视图
AddDocTemplate(pDocTemplate);在程序中,我需要根据用户的菜单选择,来切换视图到CNoTwoParaView。以下是用户下达切换菜单后,我的处理过程:
{
CView* pOldActiveView = this->GetActiveView();
CView* pNewActiveView = (CView*) m_pNoTwoParaView ; if (pNewActiveView)
{
if (pOldActiveView == pNewActiveView) return; SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(m_nCurrentViewID);
m_nCurrentViewID = 11; RecalcLayout();
}
}
BOOL CReManageApp::InitInstance() CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_RELAYMTYPE,
RUNTIME_CLASS(CReManageDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CNoOneParaView));//初始化的视图
AddDocTemplate(pDocTemplate);在程序中,我需要根据用户的菜单选择,来切换视图到CNoTwoParaView。以下是用户下达切换菜单后,我的处理过程:
{
CView* pOldActiveView = this->GetActiveView();
CView* pNewActiveView = (CView*) m_pNoTwoParaView ; if (pNewActiveView)
{
if (pOldActiveView == pNewActiveView) return; SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(m_nCurrentViewID);
m_nCurrentViewID = 11; RecalcLayout();
}
}
解决方案 »
- 关于ActiveX导出结构体和常量的定义的若个问题
- 这种内存怎么释放,谢谢
- SDK中如何实现Tab键功能!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- 求助
- 怎样写一个让edit控件显示数据
- ADO访问数据库问题
- 这是我写的一份钩子代码!!在XP下可以运行,但在9X下有问题!!那位仁兄提示提示!!
- 急!~~谁知道如何屏蔽或替换网页中RealPlayer控件的右键菜单和控件发生错误时弹出的对话框!哪位大虾回答对了马上给分!!
- 关于vc的疑惑?
- word文档的写入问题
- CComboBoxEx类对象,可以使用SelectString函数吗?为什么每次使用都返回-1?代码如下:
- 暴怒中,看c++Primer半年,太厚了,打算天明去砍了这那本书,特来和兄弟们道别!
CloseAllDocuments(false);
pDocTemplate->OpenDocumentFile(NULL);
void CMainFrame::OnChgview()
{
CCoolSDIMenuDoc *pDoc=((CCoolSDIMenuView *)GetActiveView())->GetDocument();
CCoolSDIMenuView *pOldView=(CCoolSDIMenuView *)GetActiveView();
pDoc->AddView(m_View2) ;
m_View2->ShowWindow(SW_SHOW);
pOldView->ShowWindow(SW_HIDE);
m_View2->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldView->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1);
SetActiveView(m_View2);
pDoc->RemoveView(pOldView);
RecalcLayout();
}
class CMainFrame : public CSpawnFrameWnd
{public:
CSecondView *m_View2;
....
}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
m_View2=(CSecondView*)RUNTIME_CLASS(CSecondView)->CreateObject();
m_View2->Create(NULL, NULL, WS_CHILD,
CRect(0,0,0,0), this, IDC_VIEW, NULL);
}
RecalcLayout();
Invalidate(TURE);
void CMainFrame::OnSwitch()
{
CView *pView = GetRightPane();
if (pView == NULL)
return; CRuntimeClass *pViewClass = NULL;
if (pView->IsKindOf(RUNTIME_CLASS(CViewSwitchView)))
{
pViewClass = RUNTIME_CLASS(CRightFormView);
}
else if (pView->IsKindOf(RUNTIME_CLASS(CRightFormView)))
{
pViewClass = RUNTIME_CLASS(CViewSwitchView);
}
CRect rc;
pView->GetWindowRect(&rc);
m_wndSplitter.DeleteView(0, 1);
CCreateContext context;
context.m_pCurrentDoc = GetActiveDocument();
context.m_pCurrentFrame = this;
context.m_pLastView = NULL;
context.m_pNewDocTemplate = NULL;
context.m_pNewViewClass = pViewClass;
if (!m_wndSplitter.CreateView(0,1, pViewClass, rc.Size(), &context))
ASSERT(FALSE); m_wndSplitter.RecalcLayout();
}
CView* pTempView;
POSITION pos = m_pDoc->GetFirstViewPosition();
while (pos != NULL)
{
pTempView = m_pDoc->GetNextView(pos);
if(pTempView->IsKindOf(RUNTIME_CLASS(CXXXView)))
}