exctrls/exquestiondlg: Avoid flicker due to Activate.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8157 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-11-23 22:29:16 +00:00
parent 5e350b0270
commit 17a5b7035b
3 changed files with 255 additions and 225 deletions

View File

@ -27,8 +27,8 @@ type
FontDialog1: TFontDialog;
gbFont: TGroupBox;
gbMaxWidth: TGroupBox;
gbTest: TGroupBox;
gbTestStd: TGroupBox;
gbTest: TGroupBox;
Panel1: TPanel;
Panel2: TPanel;
rbLeftJustify: TRadioButton;
@ -38,12 +38,10 @@ type
rbVCenter: TRadioButton;
rbBottom: TRadioButton;
gbTextAlignmentLayout: TGroupBox;
HTMLBrowserHelpViewer1: THTMLBrowserHelpViewer;
HTMLHelpDatabase1: THTMLHelpDatabase;
HTMLBrowserHelpViewer: THTMLBrowserHelpViewer;
HTMLHelpDatabase: THTMLHelpDatabase;
Label1: TLabel;
Label2: TLabel;
lblResult: TLabel;
lblResultStd: TLabel;
rgGlyphShowMode: TRadioGroup;
rgMsgType: TRadioGroup;
rgPosition: TRadioGroup;
@ -79,6 +77,7 @@ uses
{$IF FPC_FullVersion >= 30202}System.{$IFEND}UITypes;
const
FORM_CAPTION = 'Test QuestionDlgEx';
DLG_TITLE = 'This is the caption of the dialog';
MSG_TEXT: array[0..6] of String = (
'msg',
@ -100,8 +99,7 @@ var
mt: Dialogs.TMsgDlgType;
res: TModalResult;
begin
lblResult.Caption := '';
Caption := FORM_CAPTION;
QuestionDlgEx_MaxWidth := seMaxWidth.Value;
QuestionDlgEx_MinWidth := seMinWidth.Value;
QuestionDlgEx_ButtonAlignment := TAlignment(rgBtnAlignment.ItemIndex);
@ -151,7 +149,7 @@ begin
3: res := QuestionDlgEx(DLG_TITLE, msg, mt, [mbYes, 'Yes sir', mbYesToAll, 'I fully agree', mbNo, 'No sir', 'IsDefault', mbNoToAll, 'I fully disagree', mbCancel, 'Changed my mind', 'IsCancel', mbClose, 'Close it', mbHelp, 'I need help'], 'HTML/index.html', X, Y);
end;
lblResult.Caption := GetModalResultStr(res);
Caption := GetModalResultStr(res);
end;
procedure TDemoForm.btnMessageDlgClick(Sender: TObject);
@ -161,7 +159,7 @@ var
msg: String;
helpkwd: String;
begin
lblResultStd.Caption := '';
Caption := FORM_CAPTION;
mt := TMsgDlgType(rgMsgType.ItemIndex);
msg := MSG_TEXT[rgMessage.ItemIndex];
helpkwd := 'HTML/index.html';
@ -173,7 +171,7 @@ begin
2: res := MessageDlg(DLG_TITLE, msg, mt, [mbYes, mbYesToAll, mbNo, mbNoToAll], helpkwd);
3: res := MessageDlg(DLG_TITLE, msg, mt, [mbYes, mbYesToAll, mbNo, mbNoToAll, mbClose, mbHelp], helpkwd);
end;
lblResultStd.Caption := GetModalResultStr(res);
Caption := GetModalResultStr(res);
end;
procedure TDemoForm.btnQuestionDlgClick(Sender: TObject);
@ -183,7 +181,7 @@ var
msg: String;
helpkwd: String;
begin
lblResultStd.Caption := '';
Caption := FORM_CAPTION;
mt := TMsgDlgType(rgMsgType.ItemIndex);
msg := MSG_TEXT[rgMessage.ItemIndex];
helpkwd := 'HTML/index.html';
@ -193,7 +191,7 @@ begin
2: res := QuestionDlg(DLG_TITLE, msg, mt, [mbYes, 'Yes sir', mbYesToAll, 'I fully agree', mbNo, 'No sir', 'IsDefault', mbNoToAll, 'I fully disagree', mbCancel, 'Changed my mind', 'IsCancel'], helpkwd);
3: res := QuestionDlg(DLG_TITLE, msg, mt, [mbYes, 'Yes sir', mbYesToAll, 'I fully agree', mbNo, 'No sir', 'IsDefault', mbNoToAll, 'I fully disagree', mbCancel, 'Changed my mind', 'IsCancel', mbClose, 'Schließen', mbHelp, 'Hilfe'], helpkwd);
end;
lblResultStd.Caption := GetModalResultStr(res);
Caption := GetModalResultStr(res);
end;
procedure TDemoForm.btnDefaultPromptDlgClick(Sender: TObject);
@ -216,7 +214,7 @@ var
X, Y: Integer;
s: String;
begin
lblResultStd.Caption := '';
Caption := FORM_CAPTION;
mt := idDialogBase + 1 + rgMsgType.ItemIndex;
msg := MSG_TEXT[rgMessage.ItemIndex];
if not TryStrToInt(edX.Text, X) then X := 0;
@ -230,7 +228,7 @@ begin
3: res := DefaultPromptDialog(DLG_TITLE, msg, mt, @btns7, 7, 2, 4, defaultPos, X, Y);
end;
// Note: res is an idButtonXXXX value here!
lblResultStd.Caption := 'Result: ' +BUTTON_NAMES[res];
Caption := FORM_CAPTION + '- Result: ' +BUTTON_NAMES[res];
end;
procedure TDemoForm.cbDefaultFontChange(Sender: TObject);
@ -255,7 +253,7 @@ var
end;
begin
lblResultStd.Caption := '';
Caption := FORM_CAPTION;
btns := TDialogButtons.Create(TDialogButton);
case rgButtons.ItemIndex of
@ -290,24 +288,23 @@ begin
btns,
0
);
lblResultStd.Caption := GetModalResultStr(res);
Caption := GetModalResultStr(res);
btns.Free;
end;
procedure TDemoForm.FormCreate(Sender: TObject);
begin
Caption := FORM_CAPTION;
cbFontName.Items.Assign(Screen.Fonts);
cbFontName.ItemIndex := Max(0, cbFontName.Items.IndexOf('Liberation Sans'));
cbFontName.Enabled := false;
seFontSize.Enabled := false;
lblResult.Caption := '';
lblResultStd.Caption := '';
end;
function TDemoForm.GetModalResultStr(res: TModalResult): String;
begin
Result := 'ModalResult: ' + {$IF FPC_FullVersion>=30202}System.{$IFEND}UITypes.ModalResultStr[res];
Result := FORM_CAPTION + ' - ModalResult: ' + {$IF FPC_FullVersion>=30202}System.{$IFEND}UITypes.ModalResultStr[res];
end;
end.