各位同学和大虾,关于一个特殊的视图切换问题,欢迎大家共同讨论!解决问题!马上给分了!!

weixiong 2002-05-13 05:19:13
大家好!我的毕业设计正处于攻坚阶段,希望大家能帮我向想办法!谢谢!!
我的程序的界面是仿照VC的界面做的,数据库ODBC,设计一个简单的人力资源管理系统。
1,左边的放置一个带有树型目录的窗口,右边用来放置无模式对话框!
2,在菜单上添加,删除,查询等按钮,分别建立了三个无模式对话框,对应添加,删除,查询三按钮。
3,要实现三无模式对话框恰好显示在右边,并且更具菜单按钮能切换。
我现先把其中两个对话框切换的代码如下:不知那里有错???????
void CMainFrame::ChangeForm(int nForm)
{
CView* pOldActiveView=GetActiveView();
CView* PNewActiveView=(CView*)GetDlgItem(nForm);
if(pNewActiveView==NULL)
{
switch (nForm)
{
case IDW_ADD_FORM;
pNewActiveView=(CView*)new CResView;
break;
case IDW_RES174_FORM;
pNewActiveView=(CView*)new CAddView;
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()==RUNTIEM_CLASS(CResView))
pOldActiveView->SetDlgCtrlID(IDW_RES174_FORM);
else
if(pOldActiveView->GetRuntimeClass()==RUNTIEM_CLASS(CAddView))
pOldActiveView->SetDlgCtrlID(IDW_ADD_FORM);
else
pOldActiveView->SetDlgCtrlID(IDW_RES174_FORM);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
}
...全文
82 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
AloneWolf 2002-05-14
  • 打赏
  • 举报
回复
我用的方法:
先Create所有view,然后对于每个view:

if(m_ActViewID==ID_VIEW_WORK)return;
m_pActiveView->SetDlgCtrlID(m_ActViewID);
m_pActiveView->ShowWindow(SW_HIDE);
SetActiveView(m_pWorkView);
m_pWorkView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_pWorkView->ShowWindow(SW_SHOW);
m_pActiveView=m_pWorkView;
m_ActViewID=ID_VIEW_WORK;
RecalcLayout();
onlynight 2002-05-14
  • 打赏
  • 举报
回复
CMainFrame里加了CView的头文件了吗?
weixiong 2002-05-13
  • 打赏
  • 举报
回复
我吧这两个改了以后还是有7个错误
MainFrm.cpp
D:\temp\Res174\MainFrm.cpp(173) : error C2065: 'RUNTIEM_CLASS' : undeclared identifier
D:\temp\Res174\MainFrm.cpp(173) : error C2275: 'CResView' : illegal use of this type as an expression
d:\temp\res174\resview.h(14) : see declaration of 'CResView'
D:\temp\Res174\MainFrm.cpp(173) : error C2446: '==' : no conversion from 'int' to 'struct CRuntimeClass *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\temp\Res174\MainFrm.cpp(173) : error C2040: '==' : 'struct CRuntimeClass *' differs in levels of indirection from 'int'
D:\temp\Res174\MainFrm.cpp(176) : error C2275: 'CAddView' : illegal use of this type as an expression
d:\temp\res174\addview.h(15) : see declaration of 'CAddView'
D:\temp\Res174\MainFrm.cpp(176) : error C2446: '==' : no conversion from 'int' to 'struct CRuntimeClass *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\temp\Res174\MainFrm.cpp(176) : error C2040: '==' : 'struct CRuntimeClass *' differs in levels of indirection from 'int'
Error executing cl.exe.

Res174.exe - 7 error(s), 0 warning(s)

onlynight 2002-05-13
  • 打赏
  • 举报
回复
CView* PNewActiveView----if(pNewActiveView==NULL)大小写
case IDW_ADD_FORM;---这里应该是冒号case IDW_ADD_FORM:
改了这两个 再编译看看还有什么错误
weixiong 2002-05-13
  • 打赏
  • 举报
回复
出错信息
Compiling...
MainFrm.cpp
H:\xiongwei\Res174\MainFrm.cpp(154) : error C2065: 'pNewActiveView' : undeclared identifier
H:\xiongwei\Res174\MainFrm.cpp(158) : error C2143: syntax error : missing ':' before ';'
H:\xiongwei\Res174\MainFrm.cpp(159) : error C2440: '=' : cannot convert from 'class CView *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
H:\xiongwei\Res174\MainFrm.cpp(161) : error C2143: syntax error : missing ':' before ';'
H:\xiongwei\Res174\MainFrm.cpp(162) : error C2248: 'CAddView::CAddView' : cannot access protected member declared in class 'CAddView'
h:\xiongwei\res174\addview.h(18) : see declaration of 'CAddView::CAddView'
H:\xiongwei\Res174\MainFrm.cpp(162) : error C2440: '=' : cannot convert from 'class CView *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
H:\xiongwei\Res174\MainFrm.cpp(167) : error C2227: left of '->Create' must point to class/struct/union
H:\xiongwei\Res174\MainFrm.cpp(168) : error C2227: left of '->OnInitialUpdate' must point to class/struct/union
H:\xiongwei\Res174\MainFrm.cpp(171) : error C2227: left of '->ShowWindow' must point to class/struct/union
H:\xiongwei\Res174\MainFrm.cpp(173) : error C2065: 'RUNTIEM_CLASS' : undeclared identifier
H:\xiongwei\Res174\MainFrm.cpp(173) : error C2275: 'CResView' : illegal use of this type as an expression
h:\xiongwei\res174\resview.h(14) : see declaration of 'CResView'
H:\xiongwei\Res174\MainFrm.cpp(173) : error C2446: '==' : no conversion from 'int' to 'struct CRuntimeClass *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
H:\xiongwei\Res174\MainFrm.cpp(173) : error C2040: '==' : 'struct CRuntimeClass *' differs in levels of indirection from 'int'
H:\xiongwei\Res174\MainFrm.cpp(176) : error C2275: 'CAddView' : illegal use of this type as an expression
h:\xiongwei\res174\addview.h(15) : see declaration of 'CAddView'
H:\xiongwei\Res174\MainFrm.cpp(176) : error C2446: '==' : no conversion from 'int' to 'struct CRuntimeClass *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
H:\xiongwei\Res174\MainFrm.cpp(176) : error C2040: '==' : 'struct CRuntimeClass *' differs in levels of indirection from 'int'
H:\xiongwei\Res174\MainFrm.cpp(180) : error C2227: left of '->SetDlgCtrlID' must point to class/struct/union
Error executing cl.exe.

Res174.exe - 17 error(s), 0 warning(s)
freelybird 2002-05-13
  • 打赏
  • 举报
回复
CView* PNewActiveView=(CView*)GetDlgItem(nForm);
你为什么要强制转换呢?难道取得的是(CDialog*)吗?你应该用CFormView


代码总的来看应该没问题
lshadow 2002-05-13
  • 打赏
  • 举报
回复
帮你up
tianlinyi 2002-05-13
  • 打赏
  • 举报
回复
:)

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧