mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 00:18:26 +02:00
TaskDialog: implement some Delphi compatible events:
- OnDialogConstructed - OnDialogCreated - OnDialogDestroyed - OnVerificationClicked Part of Issue #31399.
This commit is contained in:
parent
0bed0f65a3
commit
05c9e4aa76
@ -635,6 +635,10 @@ type
|
||||
FFooterText: TTranslateString;
|
||||
FMainIcon: TTaskDialogIcon;
|
||||
FModalResult: TModalResult;
|
||||
FOnDialogConstructed: TNotifyEvent;
|
||||
FOnDialogCreated: TNotifyEvent;
|
||||
FOnDialogDestroyed: TNotifyEvent;
|
||||
FOnVerificationClicked: TNotifyEvent;
|
||||
FQueryChoices: TStrings;
|
||||
FQueryResult: String;
|
||||
FQueryItemIndex: Integer;
|
||||
@ -685,6 +689,10 @@ type
|
||||
property VerificationText: TTranslateString read FVerificationText write FVerificationText;
|
||||
property Width: Integer read FWidth write FWidth default 0;
|
||||
property OnButtonClicked: TTaskDlgClickEvent read FOnButtonClicked write FOnButtonClicked;
|
||||
property OnDialogConstructed: TNotifyEvent read FOnDialogConstructed write FOnDialogConstructed;
|
||||
property OnDialogCreated: TNotifyEvent read FOnDialogCreated write FOnDialogCreated;
|
||||
property OnDialogDestroyed: TNotifyEvent read FOnDialogDestroyed write FOnDialogDestroyed;
|
||||
property OnVerificationClicked: TNotifyEvent read FOnVerificationClicked write FOnVerificationClicked;
|
||||
end;
|
||||
|
||||
TTaskDialog = class(TCustomTaskDialog)
|
||||
@ -709,6 +717,10 @@ type
|
||||
property VerificationText;
|
||||
property Width;
|
||||
property OnButtonClicked;
|
||||
property OnDialogConstructed;
|
||||
property OnDialogCreated;
|
||||
property OnDialogDestroyed;
|
||||
property OnVerificationClicked;
|
||||
end;
|
||||
|
||||
const
|
||||
|
@ -1660,9 +1660,27 @@ var Dlg: TTaskDialog absolute dwRefData;
|
||||
begin
|
||||
Result := S_OK;
|
||||
case uNotification of
|
||||
TDN_DIALOG_CONSTRUCTED:
|
||||
begin
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
if Assigned(Dlg.OnDialogConstructed) then
|
||||
Dlg.OnDialogConstructed(Dlg);
|
||||
end;
|
||||
TDN_CREATED:
|
||||
begin
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
if Assigned(Dlg.OnDialogCreated) then
|
||||
Dlg.OnDialogCreated(Dlg);
|
||||
end;
|
||||
TDN_DESTROYED:
|
||||
begin
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
if Assigned(Dlg.OnDialogDestroyed) then
|
||||
Dlg.OnDialogDestroyed(Dlg);
|
||||
end;
|
||||
TDN_BUTTON_CLICKED:
|
||||
begin
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
if Assigned(Dlg.OnButtonClicked) then
|
||||
begin
|
||||
CanClose := True;
|
||||
@ -1671,6 +1689,28 @@ begin
|
||||
Result := S_FALSE;
|
||||
end;
|
||||
end;
|
||||
TDN_HYPERLINK_CLICKED:
|
||||
begin
|
||||
if IsConsole then writeln('ToDo: implement OnHyperlinkClicked');
|
||||
end;
|
||||
TDN_NAVIGATED:
|
||||
begin
|
||||
if IsConsole then writeln('ToDo: implement TDN_NAVIGATED??');
|
||||
end;
|
||||
TDN_TIMER:
|
||||
begin
|
||||
if IsConsole then writeln('ToDo: implement OnTimer');
|
||||
end;
|
||||
TDN_VERIFICATION_CLICKED:
|
||||
begin
|
||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||
if Assigned(Dlg.OnVerificationClicked) then
|
||||
Dlg.OnVerificationClicked(Dlg);
|
||||
end;
|
||||
TDN_EXPANDO_BUTTON_CLICKED:
|
||||
begin
|
||||
if IsConsole then writeln('ToDo: implement OnExpanded');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -54,6 +54,11 @@ type
|
||||
procedure AddQueryCombo(var X,Y: Integer; AWidth: Integer; AParent: TWinControl);
|
||||
procedure AddQueryEdit(var X,Y: Integer; AWidth: Integer; AParent: TWinControl);
|
||||
|
||||
procedure DoDialogConstructed;
|
||||
procedure DoDialogCreated;
|
||||
procedure DoDialogDestroyed;
|
||||
procedure VerifyClicked(Sender: TObject);
|
||||
|
||||
protected
|
||||
procedure HandleEmulatedButtonClicked(Sender: TObject);
|
||||
procedure SetupControls;
|
||||
@ -62,6 +67,8 @@ type
|
||||
|
||||
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
||||
destructor Destroy; override;
|
||||
procedure AfterConstruction; override;
|
||||
|
||||
|
||||
function Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
public
|
||||
@ -240,13 +247,21 @@ begin
|
||||
FDlg := TTaskDialog(AOwner);
|
||||
RadioButtonArray := nil;
|
||||
KeyPreview := True;
|
||||
DoDialogCreated;
|
||||
end;
|
||||
|
||||
destructor TLCLTaskDialog.Destroy;
|
||||
begin
|
||||
DoDialogDestroyed;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TLCLTaskDialog.AfterConstruction;
|
||||
begin
|
||||
inherited AfterConstruction;
|
||||
DoDialogConstructed;
|
||||
end;
|
||||
|
||||
function TLCLTaskDialog.Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
var
|
||||
mRes, I: Integer;
|
||||
@ -500,6 +515,7 @@ begin
|
||||
SetBounds(X,Y,XB-X,24);
|
||||
Caption := VerificationText;
|
||||
Checked := FVerifyChecked;
|
||||
OnClick := @VerifyClicked;
|
||||
end;
|
||||
end;
|
||||
inc(Y,36);
|
||||
@ -626,6 +642,31 @@ begin
|
||||
inc(Y,42);
|
||||
end;
|
||||
|
||||
procedure TLCLTaskDialog.DoDialogConstructed;
|
||||
begin
|
||||
if Assigned(FDlg.OnDialogConstructed) then
|
||||
FDlg.OnDialogDestroyed(FDlg);
|
||||
end;
|
||||
|
||||
procedure TLCLTaskDialog.DoDialogCreated;
|
||||
begin
|
||||
if Assigned(FDlg.OnDialogCreated) then
|
||||
FDlg.OnDialogCreated(FDlg);
|
||||
end;
|
||||
|
||||
procedure TLCLTaskDialog.DoDialogDestroyed;
|
||||
begin
|
||||
if Assigned(FDlg.OnDialogDestroyed) then
|
||||
FDlg.OnDialogDestroyed(FDlg);
|
||||
end;
|
||||
|
||||
procedure TLCLTaskDialog.VerifyClicked(Sender: TObject);
|
||||
begin
|
||||
if Assigned(FDlg.OnVerificationClicked) then
|
||||
FDlg.OnVerificationClicked(FDlg);
|
||||
end;
|
||||
|
||||
|
||||
procedure TLCLTaskDialog.HandleEmulatedButtonClicked(Sender: TObject);
|
||||
var Btn: TButton absolute Sender;
|
||||
CanClose: Boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user