diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp index 5beb4aef30..9b93e39c96 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp @@ -546,7 +546,13 @@ public: void onShutDownApp(int fd, const std::string &args) { Director::getInstance()->getScheduler()->performFunctionInCocosThread([](){ - exit(0); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + extern void shutDownApp(); + shutDownApp(); +#else + exit(0); +#endif }); } private: diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp b/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp index f72f3e2468..d383352772 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp @@ -204,6 +204,12 @@ void onHelpAbout() DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_ABOUT), glfwGetWin32Window(g_eglView->getWindow()), AboutDialogCallback); } +void shutDownApp() +{ + HWND hWnd=glfwGetWin32Window(g_eglView->getWindow()); + ::SendMessage(hWnd,WM_CLOSE,NULL,NULL); +} + /*@brief new windows process*/ LRESULT CALLBACK SNewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -218,7 +224,7 @@ LRESULT CALLBACK SNewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar switch (wmId) { case ID_FILE_EXIT: - exit(0); + shutDownApp(); break; case ID_VIEW_PORTRAIT: