Search code examples
c++messagebuildervcl

Problems with MessageBox and MB_HELP


I am working with C++ Builder and I want to work with MessageBox and the clickables "OK" and "Help". When the user presses "Help", a new form should be opened. So here is my problem:

While using MessageBox and the command with MB_HELP, the Buttons "ok" and "Help" will be displayed. But when pressing Help the compiler won't do anything, he only does something and returns 1 when i am pressing Ok Button.

btw. i am with VCL-Formapplication.

Thanks for your help :)

if (Application->MessageBox("Die maximale Temperatur von 30°Grad darf nicht 
überschritten werden",
    "Warnung", MB_HELP | MB_ICONEXCLAMATION) == IDOK);
         {
            ///setting values///
         }           
else Form1->Show();   

Solution

  • I think I get it now.

    If you want to check several conditions on the same result, you can assign it to a variable first. MessageBox returns an int, so:

    int choice = Application->MessageBox("Die maximale Temperatur von 30°Grad darf nicht überschritten werden",
                                         "Warnung", MB_HELP | MB_ICONEXCLAMATION);
    if (choice == IDOK) {
        /// setting values///
    }
    else if (choice == IDHELP) {
        else Form1->Show();
    }
    

    You can of course use a switch statement. If you need information about these things, see The Definitive C++ Book Guide and List