The Message Dialog |
|
Introduction |
The MessageDlg() function is the VCL's enhanced message box and it provides a good alternative to the Win32's MessageBox() function: |
The syntaxes of the MessageDlg() function are: function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Integer): Integer; overload; function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Integer; DefaultButton: TMsgDlgBtn): Integer; overload; |
The first argument, Message, is the message addressed to the user. It can be a simple static sentence, a paragraph or any combination of strings. The IconType is an icon used to enhance the dialog box. The icon is set using a constant integer as follows:
The Buttons argument is used to specify the type(s) of
button(s) to display on the dialog box. The buttons are defined using the
TMsgDlgButtons set as follows:
The last argument is used if there is a help file available, in which case you would specify the particular index related to this message box. This message box uses the name of the project as its caption. Here is an example: procedure TForm1.btnMessageBoxClick(Sender: TObject); begin MessageDlg('All songs on the CD have been copied. Now it will be ejected.', mtInformation, [mbOK], 0) end; This would produce:
Here is another example: procedure TForm1.btnMessageBoxClick(Sender: TObject); begin MessageDlg('The file C:\Musics\tune1.wav' + ' that you are trying to upload ' + 'already exists on the server.' + sLineBreak + 'If you continue, you will replace the recent versions ' + 'of the files on the server.' + sLineBreak + 'Would you like to upload anyway?', mtConfirmation, [mbNoToAll, mbNo, mbYes, mbYesToAll], 0) end; This would produce:
|
|
||
Home | Copyright © 2010-2016, FunctionX | |
|