#include <iostream.h>
#include <stdlib.h>
then i use a int main()
but this makes the window just a simple DOS based prog
i want to make it a window with a nice title bar and stuff not a console app, how would i do that?
This is a discussion on Need some help within the C++ Programming forums, part of the General Programming Boards category; #include <iostream.h> #include <stdlib.h> then i use a int main() but this makes the window just a simple DOS based ...
#include <iostream.h>
#include <stdlib.h>
then i use a int main()
but this makes the window just a simple DOS based prog
i want to make it a window with a nice title bar and stuff not a console app, how would i do that?
o and btw i have BORLAND C++ 5.01
I assume you mean you want to make a nice windows-style gui? You need to read up on windows programming. Or Win32 API as it is properly called. Do a search on the web or on this board. There is loads of info, tutorials and source code out there. But be prepared to spend some time on it, it is quite a bit different from making console apps.
Here is a good place to start:
http://www.foosyerdoos.fsnet.co.uk/
yes a windows GUI
i have all my code done but i want to move it to a windows GUI
Code:#include <iostream.h> #include <stdlib.h> #include <lvp\string.h> int main() { // Title that will be displayed in a nice ASCII style box cout << " ******************************" << endl; cout << " **** Lab Election Program ****" << endl; cout << " ******************************" << endl << endl; // Intro to the program and intructutions for users cout << "Enter each canidates name and hit enter,"; cout << "then enter the votes for" << endl; cout << "each candidate." << endl; cout << "This program will tally the votes and display them in a easy to read table." << endl; cout <<"* Note this program does"; cout << "not allow spaces for each name, but does allow negative numbers" << endl; cout << endl; // Enter the names (no spaces allowed) String Candidate1, Candidate2, Candidate3; cout << "Enter the name of the first candidate: "; cin >> Candidate1; cout << "Enter the name of the second candidate: "; cin >> Candidate2; cout << "Enter the name of the third candidate: "; cin >> Candidate3; cout << endl; // Enter the votes for each candiate for grade 10 (no letters allowed) long Votes1A, Votes2A, Votes3A; cout << "Enter the votes for " << Candidate1 << " in grade 10: "; cin >> Votes1A; cout << "Enter the votes for " << Candidate2 << " in grade 10: "; cin >> Votes2A; cout << "Enter the votes for " << Candidate3 << " in grade 10: "; cin >> Votes3A; cout << endl; // Enter the votes for each candiate for grade 11 long Votes1B, Votes2B, Votes3B; cout << "Enter the votes for " << Candidate1 << " in grade 11: "; cin >> Votes1B; cout << "Enter the votes for " << Candidate2 << " in grade 11: "; cin >> Votes2B; cout << "Enter the votes for " << Candidate3 << " in grade 11: "; cin >> Votes3B; cout << endl; // Enter the votes for each candidate for grade 12 long Votes1C, Votes2C, Votes3C; cout << "Enter the votes for " << Candidate1 << " in grade 12: "; cin >> Votes1C; cout << "Enter the votes for " << Candidate2 << " in grade 12: "; cin >> Votes2C; cout << "Enter the votes for " << Candidate3 << " in grade 12: "; cin >> Votes3C; cout << endl; // Define the Percentage for each candidate long VotesTotal = Votes1A + Votes2A + Votes3A + Votes1B + Votes2B + Votes3B + Votes1C + Votes2C + Votes3C; double Percent1 = 100 * double (Votes1A + Votes1B + Votes1C)/VotesTotal; double Percent2 = 100 * double (Votes2A + Votes2B + Votes2C)/VotesTotal; double Percent3 = 100 * double (Votes3A + Votes3B + Votes3C)/VotesTotal; const int ColWidth = 10; cout.setf(ios::fixed); cout.precision(2); // Display the colum headings. cout << "-----------------------------------------------------" <<endl; cout.setf(ios::left); cout.width(ColWidth); cout << "Candidate"; cout.setf(ios::right); cout.width(ColWidth); cout << "Votes 10"; cout.width(ColWidth); cout << "Votes 11"; cout.width(ColWidth); cout << "Votes 12"; cout.width(ColWidth); cout << "Percent" << endl; cout << "-----------------------------------------------------" <<endl; //Output Results For Candidate 1, Name-Votes-Percent cout.setf(ios::left); cout.width(ColWidth); cout << Candidate1; cout.setf(ios::right); cout.width(ColWidth); cout << Votes1A; cout.width(ColWidth); cout << Votes1B; cout.width(ColWidth); cout << Votes1C; cout.width(ColWidth); cout << Percent1 << endl; // Output for Candiate 2, Name-Votes-Percent cout.setf(ios::left); cout.width(ColWidth); cout << Candidate2; cout.setf(ios::right); cout.width(ColWidth); cout << Votes2A; cout.width(ColWidth); cout << Votes2B; cout.width(ColWidth); cout << Votes2C; cout.width(ColWidth); cout << Percent2 << endl; // Output for Candiate 3, Name-Votes-Percent cout.setf(ios::left); cout.width(ColWidth); cout << Candidate3; cout.setf(ios::right); cout.width(ColWidth); cout << Votes3A; cout.width(ColWidth); cout << Votes3B; cout.width(ColWidth); cout << Votes3C; cout.width(ColWidth); cout << Percent3 << endl; // Total Votes and percent each cout << "-----------------------------------------------------" <<endl; cout.width(ColWidth); cout << "TOTAL: "; cout.width(ColWidth); cout << VotesTotal << endl; cout << "-----------------------------------------------------" <<endl; cout << endl; system("PAUSE"); return 0; }
well, look for visual c++ to learn windows programming
you can get nice tutorials from microsoft press![]()
There was a recent post titled "Going into windows programming" Lots of good disussion there. Windows programming is NOT trivial! Petzold's first "Hello Windows" example (From his book "Programming Windows") is about 50 lines of code!!!
[EDIT]
For future reference... "Need some help" is a "bad" title.See the FAQ. Some people don't even read posts with non-specific titles.
Last edited by DougDbug; 03-06-2003 at 12:50 PM.
Your code will need to be ported to Win API or apple api or whatever if you want to use a graphical user interface to interact with the user and display that interaction visually. WinAPI and wrapper classes to WinAPI like MFC and VCL don't use cout or cin to accept user input or display to the screen. Instead GUIs use events to indicate input, trigger displays, and draws text to the screen. Any of the displaying/drawing is done via a device context of one form or another depending how and where you are going to display/draw/render the graphical image. It is a doable task and a laudable goal to port the code to a GUI, but it's not a trivial matter.