This is my main loop:

    while(TRUE)
    {

    PeekMessage(&msg,hWnd,0,0,PM_REMOVE);
        if (msg.message==WM_QUIT)
            break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);


    }

and this is my callback procedure:

 LRESULT CALLBACK WinProc(HWND hWnd,UINT msg1,WPARAM wParam,LPARAM lParam)
 {
    switch(msg1)
    {
        case WM_DESTROY  :
        {
            PostQuitMessage(0);
            return 0;
        }
        break;
    }

    return DefWindowProc(hWnd,msg1,wParam,lParam);
}

I found out that when I press Close button WM_NCLBUTTONDOWN will be returned by the PeekMessage function in the next loop, and no WM_QUIT!

Edit
Report