自定义类中如何获得视图类指针?急,在线等!!!

alexmayer 2004-08-09 10:32:13
如题!谢谢!
...全文
177 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
huaboy408 2004-08-09
  • 打赏
  • 举报
回复
慢慢在实践中增长经验!^_^
alexmayer 2004-08-09
  • 打赏
  • 举报
回复
谢谢huaboy408(竹一木)!!

VC牵涉的东西太多了,像我等菜鸟如何得道!
某鸟 2004-08-09
  • 打赏
  • 举报
回复
回复人: bohut(伯虎) ( ) 信誉:105 2004-08-09 10:36:00 得分: 0


CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
CyouView *pView=(CyouView *)pMain->GetActiveView();


Top

回复人: happyparrot(快乐鹦鹉) ( ) 信誉:144 2004-08-09 10:37:00 得分: 0


CMainFrame *pFrame =(CMainFrame*)(AfxGetApp()->m_pMainWnd);
C**View *pView = (C**View*)(pFrame->GetActiveView());


----------------------------
你的方法在我的程序里就不那么实用,我的程序就有2个view来回切换,呵呵
某鸟 2004-08-09
  • 打赏
  • 举报
回复
让视图类告诉他啊
huaboy408 2004-08-09
  • 打赏
  • 举报
回复
#include "LzStationDoc.h"
#include "LzStationView.h"
alexmayer 2004-08-09
  • 打赏
  • 举报
回复
……
d:\lzstation\lzstationview.h(22) : error C2143: syntax error : missing ';' before '*'
d:\lzstation\lzstationview.h(22) : error C2501: 'CLzStationDoc' : missing storage-class or type specifiers
d:\lzstation\lzstationview.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiers
D:\LzStation\LzStationView.cpp(62) : error C2440: 'initializing' : cannot convert from 'int *' to 'class CLzStationDoc *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\LzStation\LzStationView.cpp(127) : error C2556: 'class CLzStationDoc *__thiscall CLzStationView::GetDocument(void)' : overloaded function differs only by return type from 'int *__thiscall CLzStationView::GetDocument(void)'
d:\lzstation\lzstationview.h(22) : see declaration of 'GetDocument'
D:\LzStation\LzStationView.cpp(127) : error C2371: 'GetDocument' : redefinition; different basic types
d:\lzstation\lzstationview.h(22) : see declaration of 'GetDocument'
……


zjz800800 2004-08-09
  • 打赏
  • 举报
回复
强制类性转换一下肯定没问题
zjz800800 2004-08-09
  • 打赏
  • 举报
回复
楼住不会有问题的大家的答案是正确的,有可能你别的地方出错了
alexmayer 2004-08-09
  • 打赏
  • 举报
回复
添加“#include MyView.h”,上面是笔误!

错误提示:在MyView.h文件的CMyDoc *GetDocument();一行
snowx 2004-08-09
  • 打赏
  • 举报
回复
把错误贴出来把
你要调用指定的视图,还是需要包含那个头文件的
zjz800800 2004-08-09
  • 打赏
  • 举报
回复
CMainFrame * m_pf = (CMainFrame *)AfxGetMainWnd();
CyouView *m_view = (CyouView *)m_pf->GetActiveView();
bohut 2004-08-09
  • 打赏
  • 举报
回复
包含的是MyView.h吧
alexmayer 2004-08-09
  • 打赏
  • 举报
回复
我也是这样,但编译提示“CMyView”未定义。

包含CMyView.h则更加莫名其妙!
快乐鹦鹉 2004-08-09
  • 打赏
  • 举报
回复
CMainFrame *pFrame =(CMainFrame*)(AfxGetApp()->m_pMainWnd);
C**View *pView = (C**View*)(pFrame->GetActiveView());
bohut 2004-08-09
  • 打赏
  • 举报
回复
CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
CyouView *pView=(CyouView *)pMain->GetActiveView();

16,548

社区成员

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

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

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