convert console C++ to nice GUI ????

Soldato
Joined
30 Nov 2005
Posts
13,916
hi i have written a small bit of code as a learing curve for myself to make my job easier but would like to convert to a nice little GUI window app :D

just wanna enter a few names and some data, average it and print it out in a formated way . sounds easy hey? but I dont know where to start.

some comments on my coding would be nice , ( I am a noob ! by the way)


should look like this :

textbox
text box data box
text box data box
text box data box
text box data box
text box data box
text box data box
text box data box
text box data box



>>>>>>>>>>>>here is the code I have written so far which works in console

#include <iostream>

using namespace std;

void label ();

int main ()
{

float total;
int numberOfBasics;
int basicArray [8];
float amountArray [] = {0,0,0,0,0,0,0,0,0};
float endAmount [] = {0,0,0,0,0,0,0,0,0};
cout<< "my Program\n\n\n";
cout << "Please enter the number of basics: ";
cin >> numberOfBasics;


/* cout <<"Enter the tint number: ";
int tintNumber;
cin >> tintNumber;
*/
cout <<"please enter the formula total: ";
float FormulaTotal=0;
cin >> FormulaTotal;
int x = 0;

while (x < numberOfBasics)
{
int x=0;
cout <<"Enter basic: ";
cin >> basicArray [x]; // get recipe
cout <<"Enter amount: ";
cin >> amountArray [x];
++x;
}

total = amountArray[0]+ amountArray[1] + amountArray[2]
+ amountArray[3] +amountArray[4]+amountArray[5]
+amountArray[6]+amountArray[7]+amountArray[8];
x=0;
while (x < numberOfBasics)
{
x=0;
float formTotal;
endAmount[x] = amountArray[x]/total*formTotal;
++x;
}
cout<< "\n\n\nFormula\n";

x=0;

while (x < numberOfBasics)
{
x=0;
cout<< basicArray[x];
cout<< " : ";
cout<< endAmount[x];
cout<<"\n";
++x;
}

char quit[6];
cin >> quit;
return 1;
}
 
Not to easy im afraid. You have a couple of options a) Win32 API b) MFC

I prefer the win32 api for designing simple GUIs, however if you have already learnt some OOP, then you may find MFC easier.

This is a great tutorial which will show you how to make a simple window with various controls http://www.winprog.org/tutorial/index.html.

Hope thats some help, take your time and learning it properly though :)
 
tntcoder is on the money with his suggestions.

your other option is to learn a new language and implement it in C# or Java.

pro's:
GUI design is so much easier with either of these than under either than win32 or MFC. it's pretty much visual drag and drop to build the interface, the code is generated automatically from what you draw/build and then you just code up the links/actions behind the GUI components (buttons/menus/textfields etc).

con's:
You'd have to pick up a new language (though from C++ to C# or Java should be pretty much a breeze).


i've got experience of C, C++, C# and Java and generally i'd pick the language for the job. unless some other criteria forced me otherwise, i tend to use C# or Java for quick, small little apps that need a GUI.
 
Last edited:
Back
Top Bottom