I went the other way - I decided to edit the output like this (the message gets shorter, so no selection is required):
#ifdef _DEBUG static int __cdecl crtReportHookW(int nReportType, wchar_t* wszMsg, int* pnRet) { const wchar_t wszTrace[] = L"atlTraceGeneral - "; const int ccTrace = _countof(wszTrace) - 1; // exclude L'\0' if (nReportType == _CRT_WARN) { wchar_t* pwsz = wcsstr(wszMsg, wszTrace); if (pwsz != nullptr) { int ccBuf = wcslen(pwsz) + 1; // remaining buffer size (include L'\0') wmemmove_s(pwsz, ccBuf, &pwsz[ccTrace], ccBuf - ccTrace); } } return FALSE; // always keep processing }
And in the constructor of CWinApp:
#ifdef _DEBUG _CrtSetReportHookW2(_CRT_RPTHOOK_INSTALL, crtReportHookW); #endif
and a destructor derived from CWinApp:
#ifdef _DEBUG _CrtSetReportHookW2(_CRT_RPTHOOK_REMOVE, crtReportHookW); #endif
For some reason, both MCBS and widescreen versions of the hook are called with the same message, so only a wide-angle hook is needed even in the MBCS application.
source share