My question is about windows messaging. I have 2 apps, communicating through WM_COPYDATA messages. Also in the first app, there are some application defined messages. The thing is, when WM_COPDATA message processed, also app defined message is send, and WM_COPYDATA processing stops and processing goes to my message. I understand it, when I add prinnt statements. (Actually, it doesn't effect program flow.)
Let me talk briefly about program flow. With every WM_COPYDATA message, one window is opened, and when it's opened a thread is created. This thread sleeps for 4 second, then sends MM_MY_MESSAGE with SendMessage(). So, at some point WM_COPYDATA and MM_MY_MESSAGE corresponds. What I expected was, after finishing one message it will continue with the next. But it happened differently.
case WM_COPYDATA:
std::cout << "WM_COPYDATA started" << std::endl;
//
// do some stuff.
//
std::cout << "WM_COPYDATA finished" << std::endl;
return 0;
case MM_MY_MESSAGE:
std::cout << "--MM_MY_MESSAGE started--" << std::endl;
//
// do some stuff.
//
std::cout << "--MM_MY_MESSAGE finished--" << std::endl;
return 0;
Output is:
WM_COPYDATA started
WM_COPYDATA finished
WM_COPYDATA started
WM_COPYDATA finished
WM_COPYDATA started
--MM_MY_MESSAGE started--
--MM_MY_MESSAGE finished--
WM_COPYDATA finished
How 'MM_MY_MESSAGE' prints come between WM_COPYDATA prints?