mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-11 01:18:16 +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;
|
FFooterText: TTranslateString;
|
||||||
FMainIcon: TTaskDialogIcon;
|
FMainIcon: TTaskDialogIcon;
|
||||||
FModalResult: TModalResult;
|
FModalResult: TModalResult;
|
||||||
|
FOnDialogConstructed: TNotifyEvent;
|
||||||
|
FOnDialogCreated: TNotifyEvent;
|
||||||
|
FOnDialogDestroyed: TNotifyEvent;
|
||||||
|
FOnVerificationClicked: TNotifyEvent;
|
||||||
FQueryChoices: TStrings;
|
FQueryChoices: TStrings;
|
||||||
FQueryResult: String;
|
FQueryResult: String;
|
||||||
FQueryItemIndex: Integer;
|
FQueryItemIndex: Integer;
|
||||||
@ -685,6 +689,10 @@ type
|
|||||||
property VerificationText: TTranslateString read FVerificationText write FVerificationText;
|
property VerificationText: TTranslateString read FVerificationText write FVerificationText;
|
||||||
property Width: Integer read FWidth write FWidth default 0;
|
property Width: Integer read FWidth write FWidth default 0;
|
||||||
property OnButtonClicked: TTaskDlgClickEvent read FOnButtonClicked write FOnButtonClicked;
|
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;
|
end;
|
||||||
|
|
||||||
TTaskDialog = class(TCustomTaskDialog)
|
TTaskDialog = class(TCustomTaskDialog)
|
||||||
@ -709,6 +717,10 @@ type
|
|||||||
property VerificationText;
|
property VerificationText;
|
||||||
property Width;
|
property Width;
|
||||||
property OnButtonClicked;
|
property OnButtonClicked;
|
||||||
|
property OnDialogConstructed;
|
||||||
|
property OnDialogCreated;
|
||||||
|
property OnDialogDestroyed;
|
||||||
|
property OnVerificationClicked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -1660,6 +1660,24 @@ var Dlg: TTaskDialog absolute dwRefData;
|
|||||||
begin
|
begin
|
||||||
Result := S_OK;
|
Result := S_OK;
|
||||||
case uNotification of
|
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:
|
TDN_BUTTON_CLICKED:
|
||||||
begin
|
begin
|
||||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||||
@ -1671,6 +1689,28 @@ begin
|
|||||||
Result := S_FALSE;
|
Result := S_FALSE;
|
||||||
end;
|
end;
|
||||||
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -54,6 +54,11 @@ type
|
|||||||
procedure AddQueryCombo(var X,Y: Integer; AWidth: Integer; AParent: TWinControl);
|
procedure AddQueryCombo(var X,Y: Integer; AWidth: Integer; AParent: TWinControl);
|
||||||
procedure AddQueryEdit(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
|
protected
|
||||||
procedure HandleEmulatedButtonClicked(Sender: TObject);
|
procedure HandleEmulatedButtonClicked(Sender: TObject);
|
||||||
procedure SetupControls;
|
procedure SetupControls;
|
||||||
@ -62,6 +67,8 @@ type
|
|||||||
|
|
||||||
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure AfterConstruction; override;
|
||||||
|
|
||||||
|
|
||||||
function Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
function Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||||
public
|
public
|
||||||
@ -240,13 +247,21 @@ begin
|
|||||||
FDlg := TTaskDialog(AOwner);
|
FDlg := TTaskDialog(AOwner);
|
||||||
RadioButtonArray := nil;
|
RadioButtonArray := nil;
|
||||||
KeyPreview := True;
|
KeyPreview := True;
|
||||||
|
DoDialogCreated;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TLCLTaskDialog.Destroy;
|
destructor TLCLTaskDialog.Destroy;
|
||||||
begin
|
begin
|
||||||
|
DoDialogDestroyed;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLCLTaskDialog.AfterConstruction;
|
||||||
|
begin
|
||||||
|
inherited AfterConstruction;
|
||||||
|
DoDialogConstructed;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLCLTaskDialog.Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
function TLCLTaskDialog.Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||||
var
|
var
|
||||||
mRes, I: Integer;
|
mRes, I: Integer;
|
||||||
@ -500,6 +515,7 @@ begin
|
|||||||
SetBounds(X,Y,XB-X,24);
|
SetBounds(X,Y,XB-X,24);
|
||||||
Caption := VerificationText;
|
Caption := VerificationText;
|
||||||
Checked := FVerifyChecked;
|
Checked := FVerifyChecked;
|
||||||
|
OnClick := @VerifyClicked;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inc(Y,36);
|
inc(Y,36);
|
||||||
@ -626,6 +642,31 @@ begin
|
|||||||
inc(Y,42);
|
inc(Y,42);
|
||||||
end;
|
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);
|
procedure TLCLTaskDialog.HandleEmulatedButtonClicked(Sender: TObject);
|
||||||
var Btn: TButton absolute Sender;
|
var Btn: TButton absolute Sender;
|
||||||
CanClose: Boolean;
|
CanClose: Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user