
No application can do without message windows (also known as message boxes or dialog boxes). Be it to inform the user, ask for confirmation or request a decision.
As part of our own developments, we have implemented a module for the flexible programming of message windows, which I would like to present to you in this article.
Advantages
Dialog boxes can already be displayed with function WinDialogBox()
in conzept 16. The SysMsg module attached as a download at the end of the article offers several advantages over this function:
- Placeholder
Placeholders can be used in the title and text, which are replaced by replacement texts and control characters. Examples:
“\1
” – 1. Replacement text
“\n
” – Line break
“\t
” – Tabulator - Text alignment
The message text can be aligned to the left, right or centered and at the top, bottom or middle. - Enlargeable
The message window can be enlarged by the user. - Localizability
The button labels can be displayed in different languages. - Query messages
The message window can prompt the user to enter a character string or a number that can be validated during input. - Own objects
You can add your own objects to the message window. - Own buttons
You can add your own buttons to the message window.
Examples
Information

SysMsg:Msg.Info(
'Empty directory', // Title
'The directory "\1" was successfully emptied.', // Text
_Msg.Escape | _Msg.SoundNone, // Options
0, // Parent window
'MyDir' // 1. Replacement text
);
Warning

switch (SysMsg:Msg.Warn(
'Save file', // Title
'A file with the name "\1" is already available.', // Text
_Msg.Escape | _Msg.ButtonsAbortRetryIgnore, // Options
0, // Parent window
'MyFile.txt' // 1. Replacement text
))
{
// Cancel (Exit)
case _Msg.IDAbort : { /*...*/ }
// Repeat
case _Msg.IDRetry : { /*...*/ }
// Ignore
case _Msg.IDIgnore : { /*...*/ }
}
Error

SysMsg:Msg.Error(
'Import file', // Titel
'The file "\1" could not be imported.\n' +
'An error occurred while reading the XML document:\n' +
'\n' +
'Error\t: \2' +
'Line\t: \3\n' +
'Column\t: \4', // Text
_Msg.Escape | _Msg.TextAlignLeft, // Options
0, // Parent window
'MyFile.xml', // 1. Replacement text
XMLError(_XMLErrorText), // 2. Replacement text
XMLError(_XMLErrorLine), // 3. Replacement text
XMLError(_XmlErrorColumn) // 4. Replacement text
);
Confirmation

if (SysMsg:Msg.Confirm(
'Delete file', // Title
'Should the file “\1” really be deleted?\n' +
'\n' +
'Typ\t\t: \2\n' +
'Size\t\t: \3\n' +
'Modification date\t: \4', // Text
_Msg.Escape | _Msg.TextAlignLeft | _Msg.ButtonDefault2 | _Msg.Closable, // Options
0, // Übergeordnetes Fenster
'MyFile.txt', // 1. Replacement text
'XML-Dokument', // 2. Replacement text
'23,11 KB', // 3. Replacement text
'Mo., 3. Feb. 2014, 15:46 Uhr' // 4. Replacement text
// Ja
) = _Msg.IDYes)
{
// ...
}
Query

if (SysMsg:Msg.PromptAlpha(
var tName, // Value
'Rename directory', // Title
'Name:', // Text
0, // Parent window
0, // Options
'', '', '', '', '', '', '', '', // Replacement texts
__PROC__ + ':PromptValidate' // Validation function
// OK
) = _Msg.IDOK)
{
// ...
}
Customized message

// Configure message
SysMsg:Msg.Config(
'Export directory', // Title
'The “\1” directory could not be exported completely.\n' +
'The following errors have occurred:', // Text
_Msg.Escape | _Msg.IconError | _Msg.TextAlignLeft | _Msg.Resizable | _Msg.ButtonsNone, // Options
0, // Parent window
'MyDir' // 1. Replacement text
);
// Generate button
tWinButton # SysMsg:Msg.ButtonCreate('I like this!', _Msg.IDOK);
tWinButton->wpDefault # true;
tWinButton->WinFocusSet();
// Change text arrangement
SysMsg:Msg.TextAlignGroupingSet(_WinAlignGroupingTop);
// Increase minimum height
SysMsg:Msg.HeightMinSet(120, true);
tWinDataList # WinCreate(_WinTypeDataList);
tWinDataList->wpTabStop # false;
tWinDataList->wpAlignMarginTop # 8;
tWinColumn # WinCreate(_WinTypeListColumn, '', 'Datei', tWinDataList);
tWinColumn->wpClmWidth # 120;
tWinColumn # WinCreate(_WinTypeListColumn, '', 'Fehler', tWinDataList);
tWinColumn->wpClmStretch # true;
tWinDataList->WinLstDatLineAdd('MyFile.xml');
tWinDataList->WinLstCellSet('File already exists and is locked.', 2);
// ...
// Add object
SysMsg:Msg.ObjectAdd(tWinDataList);
// Display message
SysMsg:Msg.Run();
tWinDataList->WinDestroy();
Conclusion
With this module, you can design message windows according to your needs. The spacing and colors can also be individually defined in the source code. You are welcome to try out the module and give us feedback here =).
Note: Version 5.7.07 of the conzept 16 client is required to run the module correctly.