如何重载CFrameWnd::GetMessageString()

cdexs 2000-08-04 04:49:00
哪位高手能给个例子???
谢了!!!!!
...全文
165 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdexs 2000-10-29
  • 打赏
  • 举报
回复
to FBStudio:
thank u very much
hand 2000-08-05
  • 打赏
  • 举报
回复
sorry,I forgot the 'const'
sorry
FBStudio 2000-08-04
  • 打赏
  • 举报
回复
重载GetMessageString没问题,我刚测试通过
在CMainFrame的类声明中加入以下代码
virtual void GetMessageString( UINT nID, CString& rMessage ) const;
在CMainFrame的类定义文件中加入以下代码
void CMainFrame::GetMessageString( UINT nID, CString& rMessage ) const
{
if (nID==ID_FILE_NEW) rMessage="create new file";
}
编译运行吧.
hand 2000-08-04
  • 打赏
  • 举报
回复
you can override it by hand,but it seems that it was not called.
GetMessageString is a virtual function,but I think its just called
by CFrameWnd::OnSetMessageString(which invoked by WM_SETMESSAGESTRING)
so it called its own implementation,not the derived one.

One method I can think out is to implement your own message handler
for WM_SETMESSAGESTRING,
so add
afx_msg LRESULT OnSetMessageString(WPARAM wParam,LPARAM lParam);
to your mainfrm.h
and add
ON_MESSAGE(0x0362/*its just the WM_SETMESSAGESTRING*/,OnSetMessageString)
to you mainfrm.cpp
of course you had to give a body to this function,
so
LRESULT CMainFrame::OnSetMessageString(WPARAM wParam,LPARAM lParam)
{
...
}
I think you should steal some code from MFC(I just tried:)
its in
...\MFC\SRC\WINFRM.CPP
line 1490-1528(BTW,it VC6.0)
you will get a error saying that two member variable cannot be
accessed when compiling you code,
I commented two line out,and it still works.
If you have more time,you can check if there lies a better answer.

16,471

社区成员

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

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

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