Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 3003|回复: 2

各种类别的提示框的使用方法

[复制链接]

该用户从未签到

发表于 2013-9-6 13:22:30 | 显示全部楼层 |阅读模式
  • procedure ShowMessage (const Msg: string);
例子(单行):
  1. program LazMessage;
  2. uses
  3.   Dialogs;
  4. begin
  5.   ShowMessage('This is a message from Lazarus');
  6. end.
复制代码

例子(多行):
  1. program LazMessage;
  2. uses
  3.   Dialogs;
  4. begin
  5.   ShowMessage('This is a multilines' + sLineBreak + 'message!' );
  6. end.
复制代码

  • function MessageBox (Text, Caption : PChar; Flags: Word): Integer;
例子:
  1. uses
  2.   Forms, Dialogs, LCLType;

  3. procedure DisplayMessageBox;
  4. var
  5.   Reply, BoxStyle: Integer;
  6. begin
  7.   BoxStyle := MB_ICONQUESTION + MB_YESNO;
  8.   Reply := Application.MessageBox('Press either button', 'MessageBoxDemo', BoxStyle);
  9.   if Reply = IDYES then Application.MessageBox('Yes       ', 'Reply',MB_ICONINFORMATION)
  10.     else Application.MessageBox('No         ', 'Reply', MB_ICONHAND);
  11. end;
复制代码

  • function MessageDlg (const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; HelpCtx: LongInt): Word;
例子:
  1. uses
  2.   Forms, Dialogs, LCLType, Controls;

  3. procedure TryMessageDlg;
  4. begin
  5.   if MessageDlg('Question', 'Do you wish to Execute?', mtConfirmation,
  6.    [mbYes, mbNo, mbIgnore],0) = mrYes
  7.   then { Execute rest of Program };
  8. end;
复制代码

  • function InputBox (const ACaption, APrompt, ADefault: string); string;
例子:
  1. uses
  2.   Forms, LCLType, Dialogs, Controls;

  3. procedure TryInputBox;
  4. var
  5.   UserString: string;
  6. begin
  7.   UserString := InputBox('Get some text input',
  8.     'Please type in some information', 'Some sample text');
  9.   ShowMessage(UserString)
  10. end;
复制代码

  • function InputQuery (const ACaption, APrompt: string; var Value: string): Boolean;
例子:
  1. uses
  2.   Forms, LCLType, Dialogs, Controls;

  3. procedure TryInputQuery;
  4. var
  5.   QueryResult: Boolean;
  6.   UserString: string;
  7. begin
  8.   if InputQuery('Question', 'Type in some data', TRUE, UserString)
  9.   then ShowMessage(UserString)
  10.   else
  11.   begin
  12.     InputQuery('Don''t be silly', 'Please try again', UserString);
  13.     ShowMessage(UserString);
  14.   end
  15. end;
复制代码

  • function PasswordBox(const ACaption, APrompt : String) : String;
类似InputQuery的方式,需要设置MaskInput = TRUE;

回复

使用道具 举报

  • TA的每日心情
    开心
    2020-9-18 14:51
  • 签到天数: 47 天

    [LV.5]常住居民I

    发表于 2013-12-22 10:34:50 | 显示全部楼层
    不错的分析。谢谢。我的提高感谢fpccn的众位大师。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2014-2-4 22:03:02 | 显示全部楼层
    调用的是系统提示框?还是想delphi一样重新生成的?
    回复 支持 反对

    使用道具 举报

    *滑块验证:

    本版积分规则

    QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

    GMT+8, 2025-5-2 21:22 , Processed in 0.030957 second(s), 12 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表