来看看,这两个这样是否是一样的效果?(得到框架指针)

dingd 2002-12-10 06:14:07
出一道小题目: :)

...全文
24 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
CaptainIII 2002-12-12
  • 打赏
  • 举报
回复
查mfc的源代码吧
dingd 2002-12-12
  • 打赏
  • 举报
回复
哎,我还是半懂。
ingot 2002-12-11
  • 打赏
  • 举报
回复
学习
  • 打赏
  • 举报
回复
我和大家的意见相同
一样
dingd 2002-12-10
  • 打赏
  • 举报
回复
为什么没人说了呢?
dingd 2002-12-10
  • 打赏
  • 举报
回复
有些人还是仔细看过,和考虑过的。(不过还是有人草率的回答“一样”)

不过没人说的很透彻呀。
(还有人想混,照贴MSDN,我也有!)

我要的是透彻些的理解!

前面的几位高人,再给解释清楚些吧,谢谢
lungfun 2002-12-10
  • 打赏
  • 举报
回复
CWinThread::GetMainWnd
virtual CWnd * GetMainWnd( );

Return Value

This function returns a pointer to one of two types of windows. If your thread is part of an OLE server and has an object that is in-place active inside an active container, this function returns the CWinApp::m_pActiveWnd data member of the CWinThread object.

If there is no object that is in-place active within a container or your application is not an OLE server, this function returns the m_pMainWnd data member of your thread object
zhdleo 2002-12-10
  • 打赏
  • 举报
回复
不太一样。看MSDN后觉得。
因为:
使用GetMainWnd(),那么返回的值是:
This function returns a pointer to one of two types
of windows.
表示有2种情况。

情况一:
If your thread is part of an OLE server
and has an object that is in-place active inside an
active container, this function returns the
CWinApp::m_pActiveWnd data member of the CWinThread object.

我有一点不明白:
这个CWinApp::m_pActiveWnd怎么是data member of the CWinThread object?
CWinApp::m_pActiveWnd不是应该是data member of the CWinApp object。
虽然CWinThread也有CWinThread::m_pActiveWnd。
但“CWinApp::m_pActiveWnd data member of the CWinThread object”这句话
是不是有点不太合适呢?还是我理解有偏差?

情况二:
If there is no object that is in-place active within
a container or your application is not an OLE server,
this function returns the m_pMainWnd data member of your thread object.

可见2个还是有差别的。
GZCompiler 2002-12-10
  • 打赏
  • 举报
回复
看看,我觉得一般来说是一样的,不过正如楼上所说,有意外的时候。
FloatSea 2002-12-10
  • 打赏
  • 举报
回复
This function returns a pointer to one of two types of windows. If your thread is part of an OLE server and has an object that is in-place active inside an active container, this function returns the CWinApp::m_pActiveWnd data member of the CWinThread object.

If there is no object that is in-place active within a container or your application is not an OLE server, this function returns the m_pMainWnd data member of your thread object.
由此看来不同啊,只是在If there is no object that is in-place active within a container or your application is not an OLE server时是一样的!!
andy_lau 2002-12-10
  • 打赏
  • 举报
回复
一样的
其实
GetMainWnd()
{
return m_pMainWnd;
}
andy_lau 2002-12-10
  • 打赏
  • 举报
回复
一样的
其实
GetMainWnd()
{
return m_pMainWnd;
}
hnyyy 2002-12-10
  • 打赏
  • 举报
回复
还可以
CMainFrame* pMF=(CMainFrame*)AfxGetMainWnd();
nustchenhf 2002-12-10
  • 打赏
  • 举报
回复
CWinThread::GetMainWnd
virtual CWnd * GetMainWnd( );

Return Value

This function returns a pointer to one of two types of windows. If your thread is part of an OLE server and has an object that is in-place active inside an active container, this function returns the CWinApp::m_pActiveWnd data member of the CWinThread object.

If there is no object that is in-place active within a container or your application is not an OLE server, this function returns the m_pMainWnd data member of your thread object.
jason_sun22 2002-12-10
  • 打赏
  • 举报
回复
我认为GetMainWnd()就是通过函数得到m_pMainWnd。
用户 昵称 2002-12-10
  • 打赏
  • 举报
回复
i think is same
dingd 2002-12-10
  • 打赏
  • 举报
回复
CMainFrame* pMF=(CMainFrame*)AfxGetApp()->GetMainWnd();

CMainFrame* pMF=(CMainFrame*)AfxGetApp()->m_pMainWnd;
一样吗?

大家来说说!

16,472

社区成员

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

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

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