Hello everyone,

i have written a program in c++ using Microsoft visual studio which runs perfectly, at least to my satisfaction. However i thought it would be nice to create a graphical user interface to it, and i have used
Ms Visual C++ to design one and Visual c++ can generate the code easily. however, i am a newbie in this and dont know how to integrate this into my program, or vice versa....

Anyone has an idea how to do this?
Thanks in advance for the advice!

Recommended Answers

All 3 Replies

weeeeelll.... You are asking a bit much, coz writing a GUI depends entirely on the application and its requirement, but I will try to point you in a direction to get you started.
MSVC uses "wizards" to create different kinds of projects. You must have used some already as you have a commandline application. One way to create a GUI is to use a wizard like Single Document or multiple Document application. Those are MFC (Microsoft Foundation classes) projects and the wizard will create a project for you that you can compile and run without the need to write a line of code. You should first try a Dialog-based application. This also will create the code that compiles and serve as a basis for your program. After creation you will see an empty panel on which you can drag and drop graphical elements like buttons, text windows, etc.
Just do that for a start and recompile. When you run the executable you'll see the GUI as you created it, but it won't do much. Now in MSVC double click on one of the buttons you dragged on the panel. This will open a code window for you inside the handler function for the onClick event. replace the to-do comment with the following:

AfxMessageBox("Hello from sofiastrange");

Recompile and execute. Press on the button and Wahey! you created your first user-interface.
That's just a start and you'll have a lot to pick up if you've never done it before, but hey: Good luck! We all had to go through this ;-)

weeeeelll.... You are asking a bit much, coz writing a GUI depends entirely on the application and its requirement, but I will try to point you in a direction to get you started.
MSVC uses "wizards" to create different kinds of projects. You must have used some already as you have a commandline application. One way to create a GUI is to use a wizard like Single Document or multiple Document application. Those are MFC (Microsoft Foundation classes) projects and the wizard will create a project for you that you can compile and run without the need to write a line of code. You should first try a Dialog-based application. This also will create the code that compiles and serve as a basis for your program. After creation you will see an empty panel on which you can drag and drop graphical elements like buttons, text windows, etc.
Just do that for a start and recompile. When you run the executable you'll see the GUI as you created it, but it won't do much. Now in MSVC double click on one of the buttons you dragged on the panel. This will open a code window for you inside the handler function for the onClick event. replace the to-do comment with the following:

AfxMessageBox("Hello from sofiastrange");

Recompile and execute. Press on the button and Wahey! you created your first user-interface.
That's just a start and you'll have a lot to pick up if you've never done it before, but hey: Good luck! We all had to go through this ;-)

Thanks for the quick reply! My prg demonstrates the RSA encryption system in c++. i have already designed the graphical elements and stuff, and need the first few specific steps, showing me to put what where.... the highlighted part of your answer seems to be the answer to my question. I have how ever outran my beginners luck... may i send u a snippet of the codes so u take a look?

go ahead! we'll have a look.

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.