|
- procedure ShowMessage (const Msg: string);
例子(单行):
- program LazMessage;
- uses
- Dialogs;
- begin
- ShowMessage('This is a message from Lazarus');
- end.
复制代码
例子(多行):
- program LazMessage;
- uses
- Dialogs;
- begin
- ShowMessage('This is a multilines' + sLineBreak + 'message!' );
- end.
复制代码
- function MessageBox (Text, Caption : PChar; Flags: Word): Integer;
例子:
- uses
- Forms, Dialogs, LCLType;
-
- procedure DisplayMessageBox;
- var
- Reply, BoxStyle: Integer;
- begin
- BoxStyle := MB_ICONQUESTION + MB_YESNO;
- Reply := Application.MessageBox('Press either button', 'MessageBoxDemo', BoxStyle);
- if Reply = IDYES then Application.MessageBox('Yes ', 'Reply',MB_ICONINFORMATION)
- else Application.MessageBox('No ', 'Reply', MB_ICONHAND);
- end;
复制代码
- function MessageDlg (const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; HelpCtx: LongInt): Word;
例子:
- uses
- Forms, Dialogs, LCLType, Controls;
-
- procedure TryMessageDlg;
- begin
- if MessageDlg('Question', 'Do you wish to Execute?', mtConfirmation,
- [mbYes, mbNo, mbIgnore],0) = mrYes
- then { Execute rest of Program };
- end;
复制代码
- function InputBox (const ACaption, APrompt, ADefault: string); string;
例子:
- uses
- Forms, LCLType, Dialogs, Controls;
-
- procedure TryInputBox;
- var
- UserString: string;
- begin
- UserString := InputBox('Get some text input',
- 'Please type in some information', 'Some sample text');
- ShowMessage(UserString)
- end;
复制代码
- function InputQuery (const ACaption, APrompt: string; var Value: string): Boolean;
例子:
- uses
- Forms, LCLType, Dialogs, Controls;
-
- procedure TryInputQuery;
- var
- QueryResult: Boolean;
- UserString: string;
- begin
- if InputQuery('Question', 'Type in some data', TRUE, UserString)
- then ShowMessage(UserString)
- else
- begin
- InputQuery('Don''t be silly', 'Please try again', UserString);
- ShowMessage(UserString);
- end
- end;
复制代码
- function PasswordBox(const ACaption, APrompt : String) : String;
类似InputQuery的方式,需要设置MaskInput = TRUE;
|
|