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;
效果: