How to use a MFC's Class in Console?

D

dolphin

Hi!Nice to see you!
I hava a problem.
How to use a MFC's Class in Console?For example I want to use CString
in a win32 console program.What should I do?Sorry for my poor English.
 
S

Sarath

Hi!Nice to see you!
I hava a problem.
How to use a MFC's Class in Console?For example I want to use CString
in a win32 console program.What should I do?Sorry for my poor English.

It's possible to use CString in non-mfc programs.
You all need to include atlstr.h in your source file. It will work
fine.
#include <atlstr.h>
 
S

Sarath

Hi!Nice to see you!
I hava a problem.
How to use a MFC's Class in Console?For example I want to use CString
in a win32 console program.What should I do?Sorry for my poor English.

My previous answer was based on Visual C++ 7.1 onwards.

In Visual C++ 6.0

You have to
* Include 'afx.h' in one of your main headers
* Open the menu 'Project -> Settings'. On the 'General' register
of the settings dialog box choose 'Use MFC in a Shared DLL' or 'Use
MFC in a Static Library' from the drop down box called 'Microsoft
Foundation Classes'.

now you can use CString in your application. But it's adviced to use
std::string or std::wstring instead of CString in Pure C++
applications. else your code will not be portable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top