1
내가 다음 코드를GetMessage 함수 /를 PeekMessage -
SendApp을 때 클릭 버튼 [X]를, 다음 코드
HWND pHWndReceiveApp = FindWindowA(NULL, "ReceiveApp");
if (NULL == pHWndReceiveApp)
{
MessageBox(0, MSG_FAIL, CAPTION, 0);
return;
}
for (int i = 0; i < 7; i++)
{
PostMessageA(pHWndReceiveApp, 9, 9, 0);
}
MessageBox(0, MSG_OK, CAPTION, 0);
ReceiveApp을 실행 메시지 큐에있는 모든 메시지를 제거, 이것은 단지 응용 프로그램입니다 당신이 볼 수 그래서, 내가 ReceiveApp 증가 변수 내가 전에 메시지 큐에있는 모든 메시지를 제거 할 SendApp 메시지
int i = 0;
msg.message = 69;
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0)
{
if (msg.message == 9)
{
//I want to remove all messages in the message queue before increase i
++i;
Sleep(1000);
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
을받을 수 있습니다. 난 this article를 읽고 그
PM_REMOVE 볼 - 메시지를 PeekMessage 의해 처리 후의 큐로부터 제거된다.
나는 SendApp에서 [X] 버튼을 누르면 ReceiveApp의 변수 i가 여전히 7 씩 증가한다는 것을 알았습니다.
그래서 메시지 대기열에있는 모든 메시지를 제거 할 수 있습니까?