[Back To Directory]

MessageBox(NULL, "Message", "Title Text", MB_OK);

1. Open Borland C++ Builder.
2. Place a Button on the form.
3. Place a CheckBox on the form.
4. Double click Button1.
5. Type the following red code in the Button1Click function:

//This is what the Button1Click function should look like:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   if(CheckBox1->Checked)
      MessageBox(Application->Handle, "Hello Message", "Hello Title Bar", MB_OK);
   else
      MessageBox(NULL, "Hello Message", "Hello Title Bar", MB_OK);
}
//---------------------------------------------------------------------------


6. Run the program, each time the button is pushed, a message box is displayed.

Now click on the form and the messagebox will move behind the form. Do this a few times and then move the form to see behind it. All the message boxes are there. Now check the box, then push the button. Try to click the form again, the for apperas to be disabled until you click the message box away. This is because Application->Handle was passed as the first paramenter of the MessageBox function if the check box is checked.


//MesageBox can also be used in an if statement:
if(MessageBox(Application->Handle, "Continue? /n/n Yes or No", "Continue", MB_YESNO) == IDYES)
   Label1->Caption = "You clicked yes";
else
   Label1->Caption = "You clicked no";




[Back To Directory]