Recursively calling your class member function window procedure (WinMsgHandler) by default is not a good idea; replace the default of the switch statment with a call to DefWindowProc instead:You might want to read up on GetMessage, too; there's a possibility of that function returning -1, a result which will break your code.Code:LRESULT CALLBACK CWindow::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CREATE: MessageBox(NULL, "Create", "test", MB_OK); break; case WM_CLOSE: /*default system processing of WM_CLOSE involves a call to DestroyWindow so if you intercept this message, do the same*/ DestroyWindow(hwnd); PostQuitMessage(0); break; default: //return CWindow::WinMsgHandler(hwnd, uMsg, wParam, lParam); DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }