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!

Edited by Carrots: n/a

7 Years
Discussion Span
Last Post by Carrots

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.

Edited by Ancient Dragon: n/a

Votes + Comments
Thanks buddy! :)

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.


Edited by Carrots: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.