---
title: "MessageBox (Basic)"
canonical: "https://docs.cuesystem.com/space/CVCGC/402784272/MessageBox%20(Basic)"
format: markdown
---
> Macro (toc)

---

# Description

MessageBox is a resizable container with a caption and area for a message. You can select the openmode of this container. This object is typically used in control application to display information to the user or to get a response if needed. The MessageBox can be used as a container for other objects, for example, buttons, static texts, etc.

![image](media://988d7e2e-0f2a-45b4-b6f0-b8cbaa24e827)

You can place any objects on the MessageBox as described in the following figure.

![image](media://d5cd9ae7-957b-48b9-9fcf-40075f1d9f66)

# Properties

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| NavigationBarButtonID | Long | 0 to Maximum number of buttons in joined Navigation Bar | 0 | Value for joining Navigation Bars with MessageBox. |
| OpenMode | Long | _OW_MODAL = Modal   
0 = Modeless _OW_TOPMOST = Topmost | _OW_TOPMOST | OpenMode of window. See CVC help Commands/ BaseGraphicWindow/Open for description of _OW... constants and available OpenModes |
| Caption |
| CaptionAlign | Long | Meaningfull BitOr combinations of _TEXT_ALIGN... constants | _TEXT_ ALIGNHCENTER<br>BitOr _TEXT_ ALIGNVCENTER | Horizontal and vertical align of caption text. See CVC help Commands/ BaseGraphicClass/DrawText for description of _TEXT_ ALIGN... commands |
| CaptionFont | AddressOf _Font | Any | fntDefault16 | Caption font. fntDefault16 is Verdana 16 pixels high. |
| CaptionText | AddressOf Text | Any | “Caption” | Text shown in Caption |
| Message |
| MessageAlign | Long | Meaningfull BitOr combinations of _TEXT_ALIGN... constants | _TEXT_ ALIGNHCENTER<br>BitOr _TEXT_ ALIGNVCENTER | Horizontal and vertical align of message text. See CVC help Commands/ BaseGraphicClass/DrawText for description of _TEXT_ ALIGN... commands |
| MessageFont | AddressOf _Font | Any | fntDefault16 | Message font. fntDefault16 is Verdana 16 pixels high. |
| MessageText | AddressOf Text | Any | “Message” | Text shown in Message field. |

> 📝 #### Note
> 📝 
> 📝 NavigationBarButtonID is a property used for joining MessageBox with the navigation bar. If the navigation bar has the same join as this MessageBox and button with corresponding NavigationBarButtonID is pressed on navigation bar, this MessageBox will open. If another button on navigation bar is pressed, this MessageBox will close. If navigation bar has a different join, visibility of this MessageBox is not managed by the navigation bar.

# Functions

## SetCaptionAlign

This function sets CaptionAlign. You can use meaningful BitOr combinations of following constants as parameter

- _TEXT_ALIGNLEFT
- _TEXT_ALIGNHCENTER
- _TEXT_ALIGNRIGHT
- _TEXT_ALIGNTOP
- _TEXT_ALIGNVCENTER
- _TEXT_ALIGNBOTTOM

The function returns True on success or False if an error occurs (parameter has wrong value).

#### Syntax

```visualbasic
Function SetCaptionAlign(newcaptionalign As Long) As Boolean
```

## GetCaptionAlign

This function returns current CaptionAlign of MessageBox.

#### Syntax

```visualbasic
Function GetCaptionAlign() As Long
```

## SetCaptionFont

This function sets CaptionFont. Function returns True.

#### Syntax

```visualbasic
Function SetCaptionFont(newfont As AddressOf _Font) As Boolean
```

## GetCaptionFont

This function returns addressof CaptionFont.

#### Syntax

```visualbasic
Function GetCaptionFont() As AddressOf _Font
```

## SetCaptionText

This function sets current CaptionText to newcaptiontext. As newcaptiontext you can use direct value of text (SetCaptioText (“Hello”)). In this case you will lose the possibility of changing the language of this caption. You can also use addressof text (SetCaptioText (txtHello)) as parameter (txtHello must be declared in MyCommon/Text resources). In this case it is possible to change the language of this caption. Function returns True.

#### Syntax

```visualbasic
Function SetCaptionText(newcaptiontext as Text) As Boolean
```

## GetCaptionText

This function returns addressof current CaptionText.

#### Syntax

```visualbasic
Function GetCaptionText() As AddressOf Text
```

## SetMessageAlign

This function sets CaptionAlign. You can use meaningful BitOr combinations of following constants as parameter:

- _TEXT_ALIGNLEFT
- _TEXT_ALIGNHCENTER
- _TEXT_ALIGNRIGHT
- _TEXT_ALIGNTOP
- _TEXT_ALIGNVCENTER
- _TEXT_ALIGNBOTTOM

The function returns True on success or False if an error occurs (parameter has wrong value).

#### Syntax

```visualbasic
Function SetMessageAlign(newmessagealign As Long) As Boolea
```

## GetMessageAlign

This function returns current MessageAlign of MessageBox.

#### Syntax

```visualbasic
Function GetMessageAlign() As Long
```

## SetMessageFont

This function sets MessageFont. Function returns True.

#### Syntax

```visualbasic
Function SetMessageFont(newmessagefont As AddressOf _Font) As Boolean
```

## GetMessageFont

This function returns addressof MessageFont.

#### Syntax

```visualbasic
Function GetMessageFont() As AddressOf _Font
```

## SetMessageText

This function sets current MessageText to newmessagetext. As newmessagetext you can use direct value of text (SetMessageText (“Hello”)). In this case you will lose the possibility of changing the language of this message. You can also use addressof text (SetMessageText (txtHello)) as parameter (txtHello must be declared in MyCommon/Text resources). In this case it is possible to change the language of this message. Function returns True.

#### Syntax

```visualbasic
Function SetMessageText(newmessagetext as Text) As Boolean
```

## GetMessageText

This function returns addressof current MessageText.

#### Syntax

```visualbasic
Function GetMessageText() As AddressOf Text
```

## SetOpenMode

This function sets OpenMode of window. This function has effect on next call of function ShowObject. You can use meaningful BitOr combinations of following constants as parameter:

- _OW_ALIGNBOTTOM
- _OW_ALIGNVCENTER
- _OW_ALIGNTOP
- _OW_ALIGNLEFT
- _OW_ALIGNHCENTER
- _OW_ALIGNRIGHT
- _OW_BOTTOM
- _OW_CLOSESTANDARD
- _OW_CLOSETOPMOST
- _OW_MODAL
- _OW_TOPMOST

The function returns True on success or False if an error occurs (parameter has wrong value).

#### Syntax

```visualbasic
Function SetOpenMode(newopenmode As Long) As Boolean
```

## GetOpenMode

This function returns current OpenMode of MessageBox.

#### Syntax

```visualbasic
Function GetOpenMode() As Long
```

## ShowObjectEx

This function combines opening window and CaptionText and MessageText setting and OpenMode in one command. The function returns True on success or False if an error occurs (some parameter has wrong value).

#### Syntax

```visualbasic
Function ShowObjectEx(
  newcaptiontext As Text, 
  newmessagetext As Text, 
  Optional newopenmode As Long := _OW_TOPMOST)
As Boolean
```

# Events

## OnHideObject

This event is raised whenever MessageBox has been closed.

#### Syntax

```visualbasic
Event OnHideObject As Function()
```

## OnPush

This event is raised whenever MessageBox has been pushed.

#### Syntax

```visualbasic
Event OnPush As Process()
```

## OnShowObject

This event is raised whenever MessageBox has been open.

#### Syntax

```visualbasic
Event OnShowObject As Function()
```