Hi,

I've been learning C++ these last few months, but never tried to make a GUI before.

I've wrote a program in C++ which works via the command line, but now I'm trying to create a GUI for it (MFC using Visual Studio 2005, XP host).

When I add an Edit Box to the form, then add a variable to the Edit Box, it's automatically creates a variable of type Cstring.

In my program I'm using strings (#include <string>).

Is there any problem with me simply adding the #include for strings and altering the code from CString to string?

This might sound silly, but adding the form has added sooo much code which I hardly understand and so I don't want to break it!

Thanks for any advice!

Recommended Answers

All 2 Replies

Yes because MFC doesn't know a thing about std::string. CString is the data type used by MFC to transfer strings from member variables to/from the MFC controls, such as edit box. There is a lot of code in the CView derived class that will be broken if you just simply replace CString with std::string. Until you learn how MFC works don't change a thing. Yes the compiler produces lots of code, and the MFC learning curve is about one year.

commented: Thanks buddy! :) +1

Thanks buddy!

I always figured that it was perhaps normal practice for beginner types to write a program so that it works fine within the console, and then the GUI could be added on top of it.

But reading your comments, perhaps it is important to consider the datatypes the MFC uses, and write your programs to match it's datatypes.

A GUI can't simply be 'plugged in', even though just the STL has been used.

Sucks, but an important lesson.

Appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.