---
id: "T:cAlgo.API.MessageBox"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# MessageBox (class)

A message dialog window that you can use to show a message with buttons

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

## Definition

```csharp
public static class MessageBox
```

## Examples

C#:

```csharp
var result = MessageBox.Show("Close all open positions?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
    foreach (var position in Positions.ToArray())
        ClosePosition(position);
}
```

Python:

```python
result = MessageBox.Show("Close all open positions?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question)
if result == MessageBoxResult.Yes:
    for position in list(api.Positions):
        api.ClosePosition(position)
```

## Methods

- `public static MessageBoxResult Show(string messageBoxText)` — Shows a MessageBox with just a text [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(string messageBoxText, string caption)` — Shows a MessageBox with text and caption / title [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)` — Shows a MessageBox with text, caption / title, and button [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)` — Shows a MessageBox with text, caption / title, button, and an image icon [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)` — Shows a MessageBox with text, caption / title, button, icon, and a default result [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(Window owner, string messageBoxText)` — Shows a MessageBox with text that is a child of another window [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(Window owner, string messageBoxText, string caption)` — Shows a MessageBox with text, and caption / title that is a child of another window [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button)` — Shows a MessageBox with text, caption / title, and button that is a child of another window [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)` — Shows a MessageBox with text, caption / title, button, and image icon that is a child of another window [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)
- `public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)` — Shows a MessageBox with text, caption / title, button, icon, and a default result that is a child of another window [details](https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/index.md)

