   a questionable windows wrapped class
  Below is the windows wrapped class I made.To maximize its flexibility I use std::map to construct message maps, so the class I made could be used in many different situation without any inheriting. But one bizzare thing is that the class cannot terminate properly( the window can be destroyed, but the process is always there ). Could anyone here give me some hints? :)   ...try{g_wnd = new CWindowsManager(win_param);g_wnd->Create();if(!g_wnd)throw std::runtime_error(std::string("Initialization Failed: Window::Create"));while(g_wnd->HandleMessages()){...//GameMain() can be placed here}}catch(std::runtime_error &e){::MessageBox(NULL, e.what(), "Runtime Error", MB_OK | MB_ICONERROR | MB_DEFBUTTON1 | MB_TASKMODAL| MB_TOPMOST);return -1;}HandleMessage():bool CWindowsManager::HandleMessages(){MSG message;::ZeroMemory(&message, sizeof(MSG));if(!m_hwnd)throw std::runtime_error(std::string("Window not yet created"));m_window_param.usePeekMessage ? ::PeekMessage(&message, m_hwnd, 0, 0, PM_REMOVE): ::GetMessage(&message, m_hwnd, 0, 0);if(message.message != WM_QUIT){::TranslateMessage(&message);::DispatchMessage(&message);return true;}return false;}Maybe the most weird thing is, if I change my code like this, everything is fine:try{g_wnd = new CWindowsManager(win_param);g_wnd->Create();if(!g_wnd)throw std::runtime_error(std::string("Initialization Failed: Window::Create"))MSG msg;::ZeroMemory(&msg, sizeof(MSG));while(msg.message != WM_QUIT){//if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) //both OK!if(::GetMessage(&msg, 0, 0, 0)){::TranslateMessage(&msg);::DispatchMessage(&msg);}}}catch(std::runtime_error &e){::MessageBox(NULL, e.what(), "Runtime Error", MB_OK | MB_ICONERROR | MB_DEFBUTTON1 | MB_TASKMODAL| MB_TOPMOST);return -1;}Obviously, this is not an option, cause this implementation expose the message pump outside, but it just works.   
  WM_QUIT is sent as a thread message, not a window message. You need to specify NULL for the HWND parameter to PeekMessage or GetMessage to pick up messages for your current thread.   