mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 20:15:58 +02:00
merged r50789 #2df8c60e2b,r50790: QuestionDlg fixes
git-svn-id: branches/fixes_1_6@50791 -
This commit is contained in:
parent
033d704341
commit
3d19486b3e
@ -2774,29 +2774,14 @@ or you can make your own set.</descr>
|
|||||||
<!-- function Visibility: default -->
|
<!-- function Visibility: default -->
|
||||||
<element name="QuestionDlg">
|
<element name="QuestionDlg">
|
||||||
<short>Show a question to the user and get a response</short>
|
<short>Show a question to the user and get a response</short>
|
||||||
<descr>QuestionDlg has the same functionality as MessageDlg <br/>
|
<descr><p>QuestionDlg has the same functionality as MessageDlg except for the parameter Buttons which is of a different type. <br/>
|
||||||
|
You can define your own captions and return values of this function.
|
||||||
except for the parameter Buttons which is of a different type. <br/>
|
</p><p>Buttons is a list of TModalResult (defined as constants [mrNone..MrYesToAll] in <link id="Controls"/>) and strings. <br/>
|
||||||
|
For each TModalResult a button is created. <br/>
|
||||||
You can define your own captions and return values of this function.<br/>
|
To set a custom caption, add a string after a button. You can use the special string parameters 'isdefault' and 'iscancel' to setup the default and cancel buttons.
|
||||||
<br/>
|
</p><p>The default TModalResults defined in controls.pp (mrNone..mrLast) don't need a caption. The default captions will be used.
|
||||||
|
</p>
|
||||||
|
</descr>
|
||||||
Buttons is a list of TModalResult (defined as constants [mrNone..MrYesToAll] in <link id="Controls"/>
|
|
||||||
|
|
||||||
) and strings. <br/>
|
|
||||||
|
|
||||||
For each TModalResult a button is
|
|
||||||
created. <br/>
|
|
||||||
|
|
||||||
To set a custom caption, add a string after a button.<br/>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The default TModalResults defined in controls.pp (mrNone..mrLast) <br/>
|
|
||||||
|
|
||||||
doesn't need a caption. The default captions will be used.</descr>
|
|
||||||
<errors/>
|
<errors/>
|
||||||
<seealso>
|
<seealso>
|
||||||
<link id="MessageDlg"/>
|
<link id="MessageDlg"/>
|
||||||
|
@ -924,42 +924,53 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// get options
|
// get options
|
||||||
CurOptions := '';
|
if (SysUtils.CompareText(CurBtnCaption,'isdefault')=0)
|
||||||
IsDefault := False;
|
or (SysUtils.CompareText(CurBtnCaption,'iscancel')=0) then
|
||||||
IsCancel := False;
|
|
||||||
if (i <= High(Buttons)) then
|
|
||||||
begin
|
begin
|
||||||
HasOptions := True;
|
HasOptions := True;
|
||||||
case Buttons[i].VType of
|
CurOptions := CurBtnCaption;
|
||||||
vtString: CurOptions := Buttons[i].VString^;
|
CurBtnCaption := '';
|
||||||
vtAnsiString: CurOptions := AnsiString(Buttons[i].VAnsiString);
|
end else
|
||||||
vtChar: CurOptions := Buttons[i].VChar;
|
begin
|
||||||
vtPChar: CurOptions := Buttons[i].VPChar;
|
CurOptions := '';
|
||||||
vtPWideChar: CurOptions := Buttons[i].VPWideChar;
|
HasOptions := False;
|
||||||
vtWideChar: CurOptions := AnsiString(Buttons[i].VWideChar);
|
if (i <= High(Buttons)) then
|
||||||
vtWidestring: CurOptions := AnsiString(WideString(Buttons[i].VWideString));
|
|
||||||
else
|
|
||||||
HasOptions := False;
|
|
||||||
end;
|
|
||||||
if HasOptions then
|
|
||||||
begin
|
begin
|
||||||
if SysUtils.CompareText(CurOptions,'isdefault')=0 then
|
HasOptions := True;
|
||||||
begin
|
case Buttons[i].VType of
|
||||||
if DialogButtons.DefaultButton <> nil then
|
vtString: CurOptions := Buttons[i].VString^;
|
||||||
raise Exception.Create('TQuestionDlg.CreateQuestionDlg only one button can be default');
|
vtAnsiString: CurOptions := AnsiString(Buttons[i].VAnsiString);
|
||||||
IsDefault := True;
|
vtChar: CurOptions := Buttons[i].VChar;
|
||||||
end else
|
vtPChar: CurOptions := Buttons[i].VPChar;
|
||||||
if SysUtils.CompareText(CurOptions,'iscancel')=0 then
|
vtPWideChar: CurOptions := Buttons[i].VPWideChar;
|
||||||
begin
|
vtWideChar: CurOptions := AnsiString(Buttons[i].VWideChar);
|
||||||
if DialogButtons.CancelButton <> nil then
|
vtWidestring: CurOptions := AnsiString(WideString(Buttons[i].VWideString));
|
||||||
raise Exception.Create('TQuestionDlg.CreateQuestionDlg only one button can be cancel');
|
else
|
||||||
IsCancel := True;
|
HasOptions := False;
|
||||||
end else
|
dec(i); // prevent the following inc(i)
|
||||||
raise Exception.Create('TQuestionDlg.CreateQuestionDlg option expected at '
|
end;
|
||||||
+IntToStr(i)+' but "'+CurOptions+'" found.');
|
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
IsDefault := False;
|
||||||
|
IsCancel := False;
|
||||||
|
if HasOptions then
|
||||||
|
begin
|
||||||
|
if SysUtils.CompareText(CurOptions,'isdefault')=0 then
|
||||||
|
begin
|
||||||
|
if DialogButtons.DefaultButton <> nil then
|
||||||
|
raise Exception.Create('TQuestionDlg.CreateQuestionDlg only one button can be default');
|
||||||
|
IsDefault := True;
|
||||||
|
end else
|
||||||
|
if SysUtils.CompareText(CurOptions,'iscancel')=0 then
|
||||||
|
begin
|
||||||
|
if DialogButtons.CancelButton <> nil then
|
||||||
|
raise Exception.Create('TQuestionDlg.CreateQuestionDlg only one button can be cancel');
|
||||||
|
IsCancel := True;
|
||||||
|
end else
|
||||||
|
raise Exception.Create('TQuestionDlg.CreateQuestionDlg option expected at '
|
||||||
|
+IntToStr(i)+' but "'+CurOptions+'" found.');
|
||||||
|
end;
|
||||||
|
|
||||||
if CurBtnCaption = '' then
|
if CurBtnCaption = '' then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user