Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Tuesday, October 10, 2006

GUI application run in console mode

//Purpose of the following code is to demonstrate a way that a GUI
program running console mode and output to console window.

BOOL CTestGuiConsoleApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a
shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically

output _bstr_t to std::ostream


std::basic_ostream<TCHAR>& operator<<(std::basic_ostream<TCHAR>& ss,
_bstr_t& v)
{
if( v.length() )
ss << (LPCTSTR)v;
return ss;
}