diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 30e267aa8b..2e063ebfe2 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -201,6 +201,25 @@ static const char* inet_ntop(int af, const void* src, char* dst, int cnt) } #endif +static const int CCLOG_STRING_TAG = 1; +void SendLogToWindow(const char *log) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + // Send data as a message + COPYDATASTRUCT myCDS; + myCDS.dwData = CCLOG_STRING_TAG; + myCDS.cbData = (DWORD)strlen(log) + 1; + myCDS.lpData = (PVOID)log; + if (Director::getInstance()->getOpenGLView()) + { + HWND hwnd = Director::getInstance()->getOpenGLView()->getWin32Window(); + SendMessage(hwnd, + WM_COPYDATA, + (WPARAM)(HWND)hwnd, + (LPARAM)(LPVOID)&myCDS); + } +#endif +} // // Free functions to log @@ -222,6 +241,7 @@ static void _log(const char *format, va_list args) OutputDebugStringW(wszBuf); WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), nullptr, FALSE); printf("%s", buf); + SendLogToWindow(buf); fflush(stdout); #else // Linux, Mac, iOS, etc diff --git a/cocos/base/CCConsole.h b/cocos/base/CCConsole.h index 1c82486a19..6d7a199d99 100644 --- a/cocos/base/CCConsole.h +++ b/cocos/base/CCConsole.h @@ -51,7 +51,6 @@ typedef SSIZE_T ssize_t; #include "base/ccMacros.h" #include "platform/CCPlatformMacros.h" - NS_CC_BEGIN /// The max length of CCLog message.