在Visual C ++ MFC中启动窗口时的事件顺序 [英] order of events when a window starts in Visual C++ MFC
问题描述
假设我有一个派生自CWnd的类,它具有事件处理函数 OnPaint
, OnCreate
和筛上部分
。当你知道所有这些都是在窗口启动时发生的,但是我想看看它们之间的顺序是什么。
当我在其中一个设置断点时,在结束函数之后,控件不是传递给另一个,并转到其中一个MFC的内置.cpp文件,例如 wincore.cpp
?
我如何理解订单?任何链接或教我一种防止控制进入MFC内置类的方法?
suppose that I have a class derived from CWnd that have the event handler functions OnPaint
,OnCreate
and OnSize
. As you know all of them are occured when the window starts but I want to see what is the order between them.
when I set a breakpoint in one of them, after ending the function, the control is not passed to another and goes to one of the MFC's built-in .cpp files for example wincore.cpp
?
How can I understand the order? any links or teach me a way to prevent the control from going to MFC built-in classes?
推荐答案
消息的顺序到达没有完全定义和记录。然而,一些消息是针对其他消息的。 MSDN明确指出, WM_NCCREATE
在 WM_CREATE
。关于 WM_CREATE
的文档在订单方面还有一些提示(强调我的):
The order in which messages arrive is not fully defined and documented. However, some messages are ordered with respect to others. The MSDN explicitly states that WM_NCCREATE
is sent prior to WM_CREATE
. The documentation for WM_CREATE
has a few more hints as far as the order is concerned (emphasis mine):
当应用程序请求通过调用
CreateWindowEx
或CreateWindow
函数创建一个窗口时发送。 (在函数返回之前发送的消息是)。新窗口的窗口过程在创建窗口后收到此消息,但在窗口变为可见之前 p>
Sent when an application requests that a window be created by calling the
CreateWindowEx
orCreateWindow
function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.
应该立即清楚,必须存在一个窗口来接收其他消息。因此,第一个 WM_SIZE
将在 WM_CREATE
之后发送。至于 WM_PAINT
它需要窗口可见。此外,它是一个低优先级的消息,仅在消息队列为空时生成。
It should be immediately clear, that a window has to exist to receive additional messages. Consequently, the first WM_SIZE
will be sent after WM_CREATE
. As for WM_PAINT
it requires that a window is visible. Plus, it is a low priority message that is only generated if the message queue is empty.
在窗口创建过程中,订单是 WM_CREATE
, WM_SIZE
, WM_PAINT
。
During window creation the order is WM_CREATE
, WM_SIZE
, WM_PAINT
.
如果您只对观察信息感兴趣,可以使用Visual Studio附带的Spy ++(spyxx.exe)工具。它可以记录任意消息,并提供详细信息。如果这是用于教育目的(而不是推导行为),这是一个非常有用的工具。
If you are only interested in observing messages you can use a tool like Spy++ (spyxx.exe) that comes with Visual Studio. It can log arbitrary messages and gives you detailed information. If this is for educational purposes (as opposed to deducing behavior) it is a very helpful tool.
注意下载人员:如果您觉得此答案不准确或需要改进,请留言以帮助未来的访客。
这篇关于在Visual C ++ MFC中启动窗口时的事件顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!