Click here to Skip to main content
13,140,231 members (50,064 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


15 bookmarked
Posted 10 Dec 2011

Convert Win32 Console Application to MFC

, 10 Dec 2011
Rate this:
Please Sign up or sign in to vote.
If you have chosen Win32 console based application while using New Project Wizard, and later you realize you need to add MFC support, here is a trick.
Assuming you have Console based application created with MFC support (i.e., you have not chosen MFC support while using New Project Wizard).

In this Tip/Trick, I am not going into detailed steps of how to create a new project and all. I assume you know all these and face a real life problem of adding MFC support to existing applications.

Follow these simple steps and your application will have MFC support.
Here I am using project name as MyApp and IDE is Visual Studio 2008.

  1. Open your project.
  2. In Project Menus --> Select MyApp Properties(MyApp -> name of my project)
  3. In Configuration Properties -> General -> Use of MFC, select Use MFC in a Shared DLL option.

  4. Add the following line in your stdafx.h file.
    #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
    #ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
    #include <afx.h>
    #include <afxwin.h>         // MFC core and standard components
    #include <afxext.h>         // MFC extensions
    #ifndef _AFX_NO_OLE_SUPPORT
    #include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
    #include <afxcmn.h>                     // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT
    #include <iostream>

Now your application has MFC support, now you can use any MFC Class, Function or Structure.

Happy programming!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Edo Tzumer5-Feb-13 1:07
memberEdo Tzumer5-Feb-13 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 10 Dec 2011
Article Copyright 2011 by Pranit Kothari
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid