User Interaction with Dialog Boxes that Generate Ouput for the User to Think about.

Hello,

I am just writing a mess around program and I am having troubles trying to figure out how to program the 'OK' button on a dialog box to display another dialog box that prompts the user whether to click 'Okay' to show that the user clicked okay, or when the user clicks 'Cancel' that it will end the program.
I have another program which asks the user a series of questions. I am trying to make it that if the user enters a number when the program asks to enter the user's name that it wont continue with the program unless the user enters a valid name and that if the user keeps inputting numbers instead of letters, that the program will loop until the user enters the correct input. The code is posted below.
I got a job at a high profile company and my position involves a lot of programming and I am willing to do anything to become amazing at programming. I am a beginner just for your information.

Program with Dialog Boxes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <windows.h>

using namespace std;

int secondBox();

int main(int argc, char *argv[])
{
    int result;
    int secondBox;

    result = MessageBox(NULL, "Hello world! \nThis is the second line.", "Hello", MB_OKCANCEL);

    if (result == IDOK) {
        cout << "You clicked okay!\n";
        cin >> secondBox;
    }

    else {
        cout << "You clicked cancel!\n";
        cout << "Thank you for using this program!\n";
    }

    cin.get();

    return 0;
}

int secondBox(int argc, char *argv[])
{
    int result;

    result = MessageBox(NULL, "You clicked okay. Good job! \nClick 'Okay' for a different window. \nClick 'Cancel' to end the program.", "The Okay Box", MB_OKCANCEL);

    if (result == IDOK) {
        cout << "You clicked okay!\n";
    }

    else {
        cout << "You clicked cancel!\n";
    }

    cin.get();

    return 0;

}


Program that asks the user a bunch of questions (not completed):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>

using namespace std;
char chr;

int main()
{
    //Declaring variables
    int age;
    string name;

    cout << "Hello person, welcome to my program!\n";
    cout << "I will ask you a series of questions\n";
    cout << "and you must answer all of them.";
    cout << "\n____________________________________\n";
    cin.ignore();
    //Asking for your name.

    cout << "I will need your name before I start\n";
    cout << "asking you questions. So... name please?\n";
    cin >> name;
    cout << "Thank you for entering your name " << name << ".\n";
    //Asking for your age.
    cout << "\n";
    cout << "Now please enter your age: \n";
    cin >> age;
        if (age < 100) {
            cout << "Wow, you are young!\n";
        }
        else if (age == 100) {
            cout << "You are pretty old.\n";
        }
        else {
            cout << "You're probably not that old...\n";
        }
    return 0;
}


Topic archived. No new replies allowed.