关于DispatchMessage函数返回的问题
MSDN 上关于该函数是这么说的
The DispatchMessage function dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function.
Syntax
LRESULT DispatchMessage( const MSG *lpmsg
);
Parameters
lpmsg
[in] Pointer to an MSG structure that contains the message.
Return Value
The return value specifies the value returned by the window procedure. Although its meaning depends on the message being dispatched, the return value generally is ignored.
Return Value里写着The return value specifies the value returned by the window procedure.意思应该是说DispatchMessage函数是要到窗口处理函数完成后才返回的(根据窗口处理函数的返回值返回嘛)
但是我在一个窗口处理函数里面写上这样的话
static int m = 0;
cout << "Message5 : \t\t\t\t" << m++ << endl;
MessageBox("5");
for (int p = 0; p < 15; ++p)
{
cout << "Message5 : \t" << p << endl;
}
它执行到MessageBox("5")后就返回了
我是这样测试的,创建一个MFC基于Dialog的程序,按下一个按钮后,发送10几个自定义的命令,按我的理解应该是每处理完一个消息,再接下去处理另外一个消息,把上面的MessageBox("5")函数去掉的话,结果确实是如此.
但是加了MessageBox("5")这句以后,情况就不是这样了,它是全部处理完MessageBox函数以前的步骤(也是按顺序来,没错),就处理下一条消息了
我想问的是,这是怎么一回事,MSDN上的DispatchMessage有特殊情况例外吗?