I created an MFC application from visual studio 2008 MFC Application template. The problem is that I want to show a console in execution and not the window created by default MFC Application template ( like the one shown when we choose Win32 Console Application template).
Can anyone please tell me how could ! display a console instead of window in an MFC application?
When you create a new Win32 Console application, the wizard has a checkbox to add common header files for MFC - check it.
This isn't very commonly done because there isn't much of MFC that's useful in a console application. You won't be running MFC's application message pump so a lot of things just won't work.
In your stdafx.h (before vs2019) or pch.h (vs2019) :
#ifdef _UNICODE
#pragma comment(linker, "/entry:wWinMainCRTStartup /subsystem:console")
#else
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console")
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With