mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:19:16 +02:00
LCL: QuestionDlg allow 'isdefault' and 'iscancel' parameters without captions
git-svn-id: trunk@50790 -
This commit is contained in:
parent
2df8c60e2b
commit
15c9d32769
@ -924,42 +924,53 @@ begin
|
||||
end;
|
||||
|
||||
// get options
|
||||
CurOptions := '';
|
||||
IsDefault := False;
|
||||
IsCancel := False;
|
||||
if (i <= High(Buttons)) then
|
||||
if (SysUtils.CompareText(CurBtnCaption,'isdefault')=0)
|
||||
or (SysUtils.CompareText(CurBtnCaption,'iscancel')=0) then
|
||||
begin
|
||||
HasOptions := True;
|
||||
case Buttons[i].VType of
|
||||
vtString: CurOptions := Buttons[i].VString^;
|
||||
vtAnsiString: CurOptions := AnsiString(Buttons[i].VAnsiString);
|
||||
vtChar: CurOptions := Buttons[i].VChar;
|
||||
vtPChar: CurOptions := Buttons[i].VPChar;
|
||||
vtPWideChar: CurOptions := Buttons[i].VPWideChar;
|
||||
vtWideChar: CurOptions := AnsiString(Buttons[i].VWideChar);
|
||||
vtWidestring: CurOptions := AnsiString(WideString(Buttons[i].VWideString));
|
||||
else
|
||||
HasOptions := False;
|
||||
end;
|
||||
if HasOptions then
|
||||
CurOptions := CurBtnCaption;
|
||||
CurBtnCaption := '';
|
||||
end else
|
||||
begin
|
||||
CurOptions := '';
|
||||
HasOptions := False;
|
||||
if (i <= High(Buttons)) 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.');
|
||||
HasOptions := True;
|
||||
case Buttons[i].VType of
|
||||
vtString: CurOptions := Buttons[i].VString^;
|
||||
vtAnsiString: CurOptions := AnsiString(Buttons[i].VAnsiString);
|
||||
vtChar: CurOptions := Buttons[i].VChar;
|
||||
vtPChar: CurOptions := Buttons[i].VPChar;
|
||||
vtPWideChar: CurOptions := Buttons[i].VPWideChar;
|
||||
vtWideChar: CurOptions := AnsiString(Buttons[i].VWideChar);
|
||||
vtWidestring: CurOptions := AnsiString(WideString(Buttons[i].VWideString));
|
||||
else
|
||||
HasOptions := False;
|
||||
dec(i); // prevent the following inc(i)
|
||||
end;
|
||||
inc(i);
|
||||
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
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user