如何在CMainFrame MessageMap中处理CChildView消息。 [英] How To Handle CChildView Messages in CMainFrame MessageMap.

查看:84
本文介绍了如何在CMainFrame MessageMap中处理CChildView消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主窗口有CMainFrame类,AppWizard生成我的视图的CChildView类。我有其他手写的类,所以我想把我的CMainFrame类作为我的操作中心。我打算将CChildView类MessageMap中的消息重新路由到CMainFrame类MessageMap。我已经尝试过使用SubclassWindow()函数,但是从一些我甚至不知道存在的库文件中继续得到错误(我是MFC的新手)。我需要帮助重新路由这些消息。指针将受到高度赞赏。谢谢。

I have CMainFrame class for my main window, and CChildView class for my view as generated by AppWizard. I have other handwritten classes, so I want to make my CMainFrame class as my center of operations. I intend to reroute the messages in the CChildView class MessageMap to CMainFrame class MessageMap. I''ve tried using SubclassWindow() function, but keep getting errors from some library files which i didnt even know exist (I''m new to MFC). Please I need help rerouting these messages. A pointer will be highly appreciated. Thanks.

推荐答案

你需要做任何这类事情。这一切都是自动完成的。 MFC中的消息路由设计为当收到消息时首先将其发送到主窗口(在您的情况下为CMainFrame)。主窗口询问所有孩子他们是否想要对邮件进行破解(路线类似于:主窗口 - >活动子项 - >文档 - >返回主窗口)。 />


因此,如果您未在子窗口中创建消息处理程序,则所有消息都将返回到主窗口。



如果通过VS中的类向导创建消息处理程序,则可以选择该窗口。只需为所有邮件选择CMainFrame就可以了。
You do need to do anything of this sort. It is all done automatically. The message routing in MFC is designed that when the message received it is first sent to the main window (CMainFrame in your case). The main window asks all the children if they''d like to have a crack on the message (The route is similar to this: Main Window -> Active Child -> Document -> Back to main window).

So, if you don''t create the message handlers in your child window, all the messages will come back to the main window.

If you create the message handlers via the Class Wizard in VS, you are able to select the window. Just select CMainFrame for all your messages and you are good.


这篇关于如何在CMainFrame MessageMap中处理CChildView消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆