Delphi Deweb中弹出式对话框的应用

1.dwMessageDialog (弹出式确认框)
函数:

procedure dwMessageDlg(AMsg,ACaption,confirmButtonCaption,cancelButtonCaption,AMethedName:String;AForm:TForm);

其中:

(1)AMsg:消息内容

(2)ACaption:消息框标题

(3)confirmButtonCaption:确定按钮标题

(4)cancelButtonCaption:取消按钮标题

(5)AMethedName:返回结果后触发Form的OnStartDock中的事件标志

(6)AForm:当前窗体,一般可以使用self

dwMessageDlg没返回值,所以不能在当前函数/过程中处理,需要等结果返回后会自动激活Form的OnStartDock函数,

所以需要在Form的OnStartDock函数中添加事件,在事件中通过以下取得前期拟触发的事件标志,对应函数中的AMethedName

dwGetProp(Self,‘interactionmethod’);

通过类似以下得到返回的结果,为’1’时表示为"确定",否则为"取消"

dwGetProp(Self,‘interactionvalue’);
弹出代码:

procedure TForm1.Button7Click(Sender: TObject);
begin
    //弹出一个确认框
    dwMessageDlg('确定要使用DeWeb吗?','我的标题','我确定','我取消','query_deweb',self);
end;

2.dwInputQuery (弹出式输入框)
函数:

procedure dwInputQuery(AMsg,ACaption,ADefault,confirmButtonCaption,cancelButtonCaption,AMethedName:String;AForm:TForm);

其中:

(1)AMsg:消息内容

(2)ACaption:消息框标题

(3)ADefault:输入框的默认值

(4)confirmButtonCaption:确定按钮标题

(5)cancelButtonCaption:取消按钮标题

(6)AMethedName:返回结果后触发Form的OnStartDock中的事件标志

(7)AForm:当前窗体,一般可以使用self

dwInputQuery没返回值,所以不能在当前函数/过程中处理,需要等结果返回后会自动激活Form的OnStartDock函数,

所以需要在Form的OnStartDock函数中添加事件,在事件中通过以下取得前期拟触发的事件标志

dwGetProp(Self,‘interactionmethod’);

通过类似以下得到返回的结果,为输入的内容。

dwGetProp(Self,‘interactionvalue’);

弹出代码:

procedure TForm1.Button8Click(Sender: TObject);
begin
    dwInputQuery('你使用的Delphi版本?','D Version','10.4.2','OK','cancel','query_version',self);
end;

用户选择后事件代码(包含前面处理dwMessageDlg的代码):

procedure TForm1.FormStartDock(Sender: TObject; var DragObject: TDragDockObject);
var
    sMethod     : string;
    sValue      : string;
begin
    sMethod     := dwGetProp(Self,'interactionmethod');
    sValue      := dwGetProp(Self,'interactionvalue');

    //
    if sMethod = 'query_deweb' then begin
        if sValue = '1' then begin
            Label2.Caption  := '选择使用DeWeb';
        end else begin
            Label2.Caption  := '再等等看';
        end;
    end else if sMethod = 'query_version' then begin
        Label3.Caption  := sValue;
    end;
end;

效果:
弹出式对话框效果
弹出式输入框效果

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值