Skip to content

MessageBox

What's MessageBox?

It's a new feature that is added on Automate API cTrader version 4.3 that allows you to easily show a dialog popup message box, it's very similar to a WPF message box if you used it then you will be able to easily use the Automate API message box.

Why Should I Use It?

You might be wondering when you can use WinForms or WPF why there is a need for an additional message box feature, it differs from WinForms and WPF because:

  1. It uses the cTrader design and theme color
  2. It doesn't require full access rights
  3. It's much easier to use it than WinForms or WPF

Usage

To use MessageBox you just have to call it's Show method and pass the parameters for text, title, buttons, icons, and default value:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        protected override void OnStart()
        {
            var result = MessageBox.Show("Text", "Title/Caption", MessageBoxButton.YesNoCancel, MessageBoxImage.Information, MessageBoxResult.Yes);

            Print(result);
        }
    }
}

The Show method has multiple overloads that you can use based on your need, for more please check the MessageBox references page.

Build and run the above cBot, you should see:

Image title

If you click any of the buttons you will see the button name on the logs tab.

You can use MessageBox anywhere on your cBot / Indicator, when you call Show method it will not return until you click any of the message box buttons, during this time all other events of your cBot / Indicator will be invoked normally.


Last update: July 1, 2022

Comments