Originally Posted by
neumee
Ive downloaded the program Code:Blocks 8.02, how would I create a application using the windows graphic mode?
Right now I'm testing my code from a console application... And which option brings the most simplicity to the programmer to design a app such as the one I'm inquiring about?
Would it be possible to help me with the syntax that creates a menu, hit <enter> on desired menu option, then it goes to next menu and so on?
(Basically the syntax to call the menu() function from the main() function would really help)
Once Again Thanks for the help
Code:
//all functions' prototypes
int invoices(void);
int unpaidInvoices(void);
int menu(void);
void printHeader(void);
void printMain(void);
//etc., one prototype for each function except main
int main(void) {
menu();
//maybe some code here
return 0; //indicates normal termination of program
}
int menu(void) {
char choice;
do {
//this is the main menu function that you program will always loop back to after
//every selection the user makes.
system("cls");
printHeader();
printMain();
//you get the user's choice, which may be based on the mouse position when it's
//clicked, or the cursor's position when you hit enter on the keyboard, or
//perhaps just a letter or number the user enters: that's all up to you.
choice = tolower(choice);
switch(choice) {
case 'i': invoices(); break;
case 'u': unpaidInvoices(); break;
//all your other cases go here, each followed by a break statement.
default: printf("That choice is not available, please choose again");
}
}while(choice != 'q');
return 0;
}
If you don't know how to code the "get choice" part of it, I'd get a small code snippet or program from a code depot site and use it as a template. I program almost entirely in console mode and do it like this:
Main Menu
Invoice
Unpaid Invoices
etc.
Cursor goes to a fixed spot on the menu screen using gotoxy(x, y). Then
Enter Your Choice: <<this is the fixed spot>>
User enters their choice of letter. Frequently, I'll highlight the first letter of each word choice, so it's easy for them to see what they want (yellow or Cyan shows up well).
If there are many entries, I'll do it this way:
1) Invoice
2) Unpaid Invoices
etc.
Enter Your Numbered Selection: <<this is the fixed spot>>
User enters a number, instead of a letter.
Note:
This is a large program that you've decided to write up. If you don't know how to even call a function, this program is out of your programming league, atm. If you don't REALLY want to work your buttinski off learning all this, I'd recommend going to Rent-A-Coder and negotiating for a coder to write it, for you. (Don't give them more $$$ than they've earned in code that you can run and see it's correct, at any time. That's true with all contractors in general.)