TWebMessageDlg
Description
Below is a list of the most important properties methods and events for TWebMessageDlg
. This component allows to display modal dialogs (simulated by disabling all controls on the page as the concept of modal dialogs does not exist in web applications).
Result for the following code:
or with an async approach:var
mr: TModalResult;
begin
mr := await(TModalResult, WebMessageDlg1.ShowDialog('Do you like TMS WEB Core?', WEBLib.Dialogs.mtConfirmation,[mbYes, mbNo]));
if mr = mrYes then
ShowMessage(‘We knew you would like it!’);
end;
Designtime | Runtime |
Properties for TWebMessageDlg
Property | Description |
---|---|
DialogResult: TModalResult | Holds the result of calling the dialog |
DialogText: TStringList | List of text used in dialog and dialog buttons. Allows for language customization of the dialog text |
ElementButtonClassName | Optionally sets the CSS classname for the buttons on the dialog when styling via CSS is used |
ElementClassName | Optionally sets the CSS classname for the label when styling via CSS is used |
ElementContentClassName | Optionally sets the CSS classname for the message content area when styling via CSS is used |
ElementDialoghClassName | Optionally sets the CSS classname for the entire dialog area when styling via CSS is used |
ElementID | Optionally sets the HTML element ID for a HTML element in the form HTML file the label needs to be connected with. When connected, no new label is created but the Delphi class is connected with the existing HTML element in the form HTML file |
ElementTitleClassName | Optionally sets the CSS classname for the dialog title area when styling via CSS is used |
Message: string | Sets the message to be displayed in the content area of the dialog |
Opacity: single | Sets the opacity level for the dialog |
Title: string | Sets the title text for the dialog |
Methods for TWebMessageDlg
Property | Description |
---|---|
ShowAsync() | Async function returning a promise. Use with pascal res := await(TModalResult, Dialog.ShowAsync; |
ShowDialog(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; AProc: TDialogResultProc = nil); | Method to show the message. The last parameter is a method pointer for a method that is optionally called when assigned when the dialog is closed |
ShowDialog(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TJSPromise; | Async version of ShowDialog() |
Events for TWebMessageDlg
Property | Description |
---|---|
OnButtonClick | Event triggered when a button on the message dialog is clicked |
OnClose | Event triggered when the messagebox is closed |
Functions for directly getting input
Two variants exist for directly calling a function instead of using a component.
procedure MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; AResultProc: TDialogResultProc = nil);
function MessageDlgAsync(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): integer;
Example with anonymous method:
begin
MessageDlg('Do you like TMS WEB Core?', mtConfirmation, [mbYes, mbNo],
procedure(res: TModalResult)
begin
if res = mrYes then
ShowMessage('Fantastic!')
else
ShowMessage('What can we do to make your experience better?');
end);
end;
Example with promise:
procedure TForm1.WebButton1Click(Sender: TObject);
var
res: TModalResult;
begin
res := await(TModalResult, MessageDlgAsync('Do you like TMS WEB Core?', mtConfirmation, [mbYes, mbNo]));
if res = mrYes then
ShowMessage('Fantastic!')
else
ShowMessage('What can we do to make your experience better?');
end;