看看《vc技术内幕》第5版的例子 EX20C
解决方案 »
- VC2010中自带的例子VisualStudioDemo中菜单图标是怎么添加的呢
- 如何改变STATIC中字体的颜色
- MFC自定义消息与postmessage函数
- 请教,如何返回程序的初始状态?各位帮忙啊!!!
- 请教如何用CView类或其它方法来显示当前时间!!!!!!
- 一个小小的初级问题
- 我编译的时候总有这样的错误,怎么回事?如何解决?
- 请教大家一个问题~~ win xp 怎么样才能像2000那样 按下 Ctrl + Alt + Del 而进行锁定? XP 真他妈的差劲!!
- 哪位兄弟知道如何打开VC的四级告警,以及任意开关其中的某些告警选项?
- 关于word自动化
- 请问各位大虾,用CMenu类的insertmenu函数插入菜单时,该函数执行后怎么使创建的菜单可见?
- 如何处理编译成功,运行出错的情况?描述在文内.....
void CMainFrame::ChangeForm(int nForm)
{
CView * pOldActiveView=GetActiveView();
CView * pNewActiveView=(CView *)GetDlgItem(nForm);
if (pNewActiveView==NULL)
{
switch(nForm)
{
case IDW_ORDER_FORM:
pNewActiveView = (CView*)new CProdView;
break;
case IDW_CUST_FORM:
pNewActiveView = (CView*)new CCustView;
break;
}
CCreateContext context;
context.m_pCurrentDoc=pOldActiveView->GetDocument();
pNewActiveView->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,nForm,&context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
if(pOldActiveView->GetRuntimeClass()==RUNTIME_CLASS(CProdView))
pOldActiveView->SetDlgCtrlID(IDW_ORDER_FORM);
else
if(pOldActiveView->GetRuntimeClass()==RUNTIME_CLASS(CCustView))
pOldActiveView->SetDlgCtrlID(IDW_CUST_FORM);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
}void CMainFrame::OnCustomer()
{
// TODO: Add your command handler code here
if(GetActiveView()->IsKindOf(RUNTIME_CLASS(CCustView)))
return;
ChangeForm(IDW_CUST_FORM);
}void CMainFrame::OnUpdateCustomer(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(GetActiveView()->IsKindOf(RUNTIME_CLASS(CCustView)));
}void CMainFrame::OnProduct()
{
// TODO: Add your command handler code here
if(GetActiveView()->IsKindOf(RUNTIME_CLASS(CProdView)))
return;
ChangeForm(IDW_ORDER_FORM);
}void CMainFrame::OnUpdateProduct(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(GetActiveView()->IsKindOf(RUNTIME_CLASS(CProdView)));
}