Visual C++ has many built-in functions that save you the trouble of having to do them yourself.

 

Let’s say that for your radio button program you want the program to bring up an error message box if they hit the calculate button before they have selected one of your radio buttons.

 

You could do this with the line below

   // This line will bring up a box with the text and title shown below

   MessageBox(_T ("You should select a radio button"), _T ("User Error"));

 

 

 

 

Look up “MessageBox” in the help index.  This will give you options for other message boxes.

Try it…it’s fun. J

 

Really…it give you options to make your program more professional looking.

 

Let’s say I want the user to answer a yes or no question:

   lsAnswer = MessageBox(

_T ("Did you mean to be an idiot and not select a radio button?"),

_T ("User Error"), MB_ICONEXCLAMATION | MB_YESNO);

 

This produces the following.

 

       

 

Notice that I added an exclamation point icon, and also changed the type of box to a Yes/No box.  I also stored their answer in a variable (although you wouldn’t necessarily have to).

 

 

If you look at the help you could use this information like so…

 

// IDYES is just the integer 6, but using the word

// "IDYES" make the program more readable

// Also note the convention that IDYES is all in caps.

// Whenever we define a constant, it should be in

// caps.  i.e. (#define IDNO 7)

if ( lsAnswer == IDYES )

{

   lsAnswer = MessageBox(

      _T ("Should I Ignore this juvenile behavior or Abort the program on you?"),

      _T ("Question for Moron"),

      MB_ICONQUESTION | MB_ABORTRETRYIGNORE);

}

 

 

 

 

So uncommonly, the Microsoft help for Visual C++ can be helpful in making your program easier to program and make it more user friendly (or less friendly to the user as the case may be).