DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: tino0914
今日帖子: 29
在线用户: 3
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 dbyoung (dbyoung) ★☆☆☆☆ -
普通会员
2021/4/29 7:21:30
标题:
分享:InputQuery 函数的妙用 浏览:1627
加入我的收藏
楼主: InputQuery 函数的妙用https://blog.csdn.net/dbyoung/article/details/116236450
----------------------------------------------
武汉天气不好
作者:
男 delphiqiw (delphi我不会) ▲▲▲△△ -
普通会员
2021/4/29 10:21:17
1楼: 学习了按此在新窗口浏览图片
----------------------------------------------
-
作者:
男 tulater (tulater) ★☆☆☆☆ -
普通会员
2021/4/29 14:28:47
2楼: if InputQuery('请输入密码:', ['密码:', '重复密码:'], strResult) then


----------
Project10
----------
Length of value array must be >= length of prompt array.
----------
确定   
----------
----------------------------------------------
http://www.cnblogs.com/tulater/
作者:
男 dmzn (dmzn) ★☆☆☆☆ -
盒子活跃会员
2021/4/29 14:35:03
3楼: 用于uniGUI的常用对话框(ShowDlg,QueryDlg,InputDlg),需要Falcon组件支持.

type
  TButtonClickType = (ctYes, ctNo, ctCancel);
  TButtonClickEvent = reference to procedure(const nType: TButtonClickType);
  TButtonClickInputEvent = reference to procedure(const nType: TButtonClickType;
    const nText: string);
  //xxxxx

  TUniMainModule = class(TUniGUIMainModule)
    procedure UniGUIMainModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    FSToast1: TUniFSToast;
    FSConfirm1: TUniFSConfirm;
    FSTheme1: UniFSConfirm.TTheme;
    {*消息框对象*}
    procedure VerifyAdministrator(const nEvent: TButtonClickInputEvent;
      const nCaller: TUniBaseForm = nil);
    {*验证身份*}
    procedure ShowMsg(const nHint: string; const nError: Boolean = False;
      nTitle: string = '');
    {*消息提示条*}
    procedure ShowDlg(const nMsg: string; const nError: Boolean = False;
      const nEvent: TButtonClickEvent = nil; nTitle: string = '');
    procedure QueryDlg(const nMsg: string; const nEvent: TButtonClickEvent = nil;
      const nMask: string = ''; nTitle: string = '');
    procedure InputDlg(const nMsg,nTitle: string;
      const nEvent: TButtonClickInputEvent; const nBlank: string = '';
      const nSize: Integer = 0; const nPwd: Boolean = False);
    {*消息提示框*}
  end;

//Date: 2021-04-20
//Parm: 消息内容;标题
//Desc: 弹出消息框
procedure TUniMainModule.ShowMsg(const nHint: string; const nError: Boolean;
  nTitle: string);
begin
  with FSToast1 do
  begin
    Close := True;
    TimeOut := 5000;

    if nError then
    begin
      if nTitle = '' then
        nTitle := sError;
      Error(nTitle, nHint, bottomRight);
    end else
    begin
      if nTitle = '' then
        nTitle := sHint;
      Info(nTitle, nHint, bottomRight);
    end;
  end;
end;

//Date: 2021-04-20
//Parm: 消息;标题
//Desc: 提示对话框
procedure TUniMainModule.ShowDlg(const nMsg: string; const nError: Boolean;
  const nEvent: TButtonClickEvent; nTitle: string);
begin
  with FSConfirm1 do
  begin
    ButtonTextConfirm  := '确定';
    ButtonTextCancel   := '取消';

    if nError then
    begin
      if nTitle = '' then
        nTitle := sError;
      //xxxxx

      Alert(nTitle, nMsg, 'fa fa-ban', red, FSTheme1,
        procedure(nButton: TConfirmButton)
        begin
          if Assigned(nEvent) then
          begin
          case nButton of
          Ok: nEvent(ctYes);
          end;
          end;
        end);
    end else
    begin
      if nTitle = '' then
        nTitle := sHint;
      //xxxxx

      Alert(nTitle, nMsg, 'fa fa-info', blue, FSTheme1,
        procedure(nButton: TConfirmButton)
        begin
          if Assigned(nEvent) then
          begin
          case nButton of
          Ok: nEvent(ctYes);
          end;
          end;
        end);
    end;
  end;
end;

//Date: 2021-04-20
//Parm: 消息;标题
//Desc: 询问对话框
procedure TUniMainModule.QueryDlg(const nMsg: string;
  const nEvent: TButtonClickEvent; const nMask: string; nTitle: string);
begin
  with FSConfirm1 do
  begin
    TypeColor := blue;
    Theme     := FSTheme1;
    RTL       := False;
    CloseIcon := False;

    ButtonTextConfirm  := '是';
    ButtonTextCancel   := '否';
    ScreenMask.Enabled := Trim(nMask) <> '';

    if ScreenMask.Enabled then
      ScreenMask.Text := nMask;
    //xxxxx

    if nTitle = '' then
      nTitle := sAsk;
    //xxxxx

    Question(nTitle, nMsg, 'fa fa-question-circle',
      procedure(nButton: TConfirmButton) //匿名回调函数
      begin
        if Assigned(nEvent) then
        begin
          case nButton of
          Yes: nEvent(ctYes);
          No:  nEvent(ctNo);
          end;
        end;
      end);
  end;
end;

//Date: 2021-04-20
//Parm: 消息;标题;事件;允许不填写;大小;是否密码
//Desc: 显示输入框
procedure TUniMainModule.InputDlg(const nMsg,nTitle: string;
  const nEvent: TButtonClickInputEvent; const nBlank: string;
  const nSize: Integer; const nPwd: Boolean);
begin
  with FSConfirm1 do
  begin
    ButtonTextConfirm  := '确定';
    ButtonTextCancel   := '取消';
    PromptType.RequiredField := nBlank <> '';
    PromptType.TextRequiredField := nBlank;

    if nPwd then
         PromptType.TypePrompt := password
    else PromptType.TypePrompt := text;

    Prompt(nTitle, nMsg, 'fa fa-keyboard-o', green, FSTheme1,
      procedure(nButton: TConfirmButton; nResult: string)
      begin
        if Assigned(nEvent) then
        begin
          if (nSize > 0) and (Length(nResult) > nSize) then
          nResult := Copy(nResult, 1, nSize);
          //xxxxx

          case nButton of
          Yes: nEvent(ctYes, nResult);
          No:  nEvent(ctNo, nResult);
          end;
        end;
      end
    );
  end;
end;
----------------------------------------------
生活愉快.
作者:
男 inbreak (入侵) ★☆☆☆☆ -
盒子活跃会员
2021/4/29 16:33:55
4楼: @tulater (tulater)

你没有搞清楚变量的定义方法;
此帖子包含附件:
PNG 图像
大小:18.9K
----------------------------------------------
我是菜鸟,己经搞了十多年了,但是我仍然很菜。
作者:
男 tulater (tulater) ★☆☆☆☆ -
普通会员
2021/4/29 16:55:46
5楼: 谢谢你 @inbreak
@inbreak
我犯了两个错
1,strResult定义为 string ;
2,没有setLength(strResult,2);
----------------------------------------------
http://www.cnblogs.com/tulater/
作者:
男 dbyoung (dbyoung) ★☆☆☆☆ -
普通会员
2021/4/29 22:09:32
6楼: @tulater:
  第一种 :strResult 是单个字符串;
  第二三种:strResult 是多个字符串(数组);具体数量是多少,取决于前一个参数字符串的多少;
  最好的办法还是去阅读 InputQuery 源码,那样是最好的。

@dmzn:
  大段代码,最好放在博客中,这里没有排版,看着很难受。
  放在博客中,也是记录自己知识积累的过程。闲时自己也可以重复看看,温故而知新。
  放论坛,没多久就淹没了。时间久了,连自己都忘记了。
  虽然我的文章水平没有武大侠万大侠等等大侠,他们那些牛人们高,但我也在学习、努力。
  共勉!
----------------------------------------------
武汉天气不好
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS