mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-09 06:58:19 +02:00
TaskDialog: add OnTimer event.
This commit is contained in:
parent
213b32e0c7
commit
70a178c88e
@ -552,6 +552,7 @@ type
|
|||||||
TTaskDialogCommonButtons = set of TTaskDialogCommonButton;
|
TTaskDialogCommonButtons = set of TTaskDialogCommonButton;
|
||||||
|
|
||||||
TTaskDlgClickEvent = procedure(Sender: TObject; AModalResult: TModalResult; var ACanClose: Boolean) of object;
|
TTaskDlgClickEvent = procedure(Sender: TObject; AModalResult: TModalResult; var ACanClose: Boolean) of object;
|
||||||
|
TTaskDlgTimerEvent = procedure(Sender: TObject; TickCount: Cardinal; var Reset: Boolean) of object;
|
||||||
|
|
||||||
TTaskDialogIcon = (tdiNone, tdiWarning, tdiError, tdiInformation, tdiShield, tdiQuestion);
|
TTaskDialogIcon = (tdiNone, tdiWarning, tdiError, tdiInformation, tdiShield, tdiQuestion);
|
||||||
|
|
||||||
@ -639,6 +640,7 @@ type
|
|||||||
FOnDialogCreated: TNotifyEvent;
|
FOnDialogCreated: TNotifyEvent;
|
||||||
FOnDialogDestroyed: TNotifyEvent;
|
FOnDialogDestroyed: TNotifyEvent;
|
||||||
FOnExpand: TNotifyEvent;
|
FOnExpand: TNotifyEvent;
|
||||||
|
FOnTimer: TTaskDlgTimerEvent;
|
||||||
FOnVerificationClicked: TNotifyEvent;
|
FOnVerificationClicked: TNotifyEvent;
|
||||||
FQueryChoices: TStrings;
|
FQueryChoices: TStrings;
|
||||||
FQueryResult: String;
|
FQueryResult: String;
|
||||||
@ -695,6 +697,7 @@ type
|
|||||||
property OnDialogDestroyed: TNotifyEvent read FOnDialogDestroyed write FOnDialogDestroyed;
|
property OnDialogDestroyed: TNotifyEvent read FOnDialogDestroyed write FOnDialogDestroyed;
|
||||||
property OnVerificationClicked: TNotifyEvent read FOnVerificationClicked write FOnVerificationClicked;
|
property OnVerificationClicked: TNotifyEvent read FOnVerificationClicked write FOnVerificationClicked;
|
||||||
property OnExpand: TNotifyEvent read FOnExpand write FOnExpand;
|
property OnExpand: TNotifyEvent read FOnExpand write FOnExpand;
|
||||||
|
property OnTimer: TTaskDlgTimerEvent read FOnTimer write FOnTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TTaskDialog = class(TCustomTaskDialog)
|
TTaskDialog = class(TCustomTaskDialog)
|
||||||
@ -724,6 +727,7 @@ type
|
|||||||
property OnDialogDestroyed;
|
property OnDialogDestroyed;
|
||||||
property OnVerificationClicked;
|
property OnVerificationClicked;
|
||||||
property OnExpand;
|
property OnExpand;
|
||||||
|
property OnTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -1656,7 +1656,7 @@ end;
|
|||||||
function TaskDialogCallbackProc(hwnd: HWND; uNotification: UINT;
|
function TaskDialogCallbackProc(hwnd: HWND; uNotification: UINT;
|
||||||
wParam: WPARAM; {%H-}lParam: LPARAM; dwRefData: Long_Ptr): HRESULT; stdcall;
|
wParam: WPARAM; {%H-}lParam: LPARAM; dwRefData: Long_Ptr): HRESULT; stdcall;
|
||||||
var Dlg: TTaskDialog absolute dwRefData;
|
var Dlg: TTaskDialog absolute dwRefData;
|
||||||
CanClose: Boolean;
|
CanClose, ResetTimer: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := S_OK;
|
Result := S_OK;
|
||||||
case uNotification of
|
case uNotification of
|
||||||
@ -1699,7 +1699,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
TDN_TIMER:
|
TDN_TIMER:
|
||||||
begin
|
begin
|
||||||
if IsConsole then writeln('ToDo: implement OnTimer');
|
{
|
||||||
|
wParam: A DWORD that specifies the number of milliseconds since the dialog was created or this notification code returned S_FALSE.
|
||||||
|
lParam: Must be zero.
|
||||||
|
Return value: To reset the tickcount, the application must return S_FALSE, otherwise the tickcount will continue to increment.
|
||||||
|
}
|
||||||
|
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||||
|
if Assigned(Dlg.OnTimer) then
|
||||||
|
begin
|
||||||
|
ResetTimer := False;
|
||||||
|
Dlg.OnTimer(Dlg, Cardinal(wParam), ResetTimer);
|
||||||
|
if ResetTimer then
|
||||||
|
Result := S_FALSE;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
TDN_VERIFICATION_CLICKED:
|
TDN_VERIFICATION_CLICKED:
|
||||||
begin
|
begin
|
||||||
|
@ -7,7 +7,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
LazUTF8,
|
LazUTF8,
|
||||||
LCLType, LCLStrConsts, LCLIntf, InterfaceBase, ImgList, LCLProc,
|
LCLType, LCLStrConsts, LCLIntf, InterfaceBase, ImgList, LCLProc, DateUtils,
|
||||||
LResources, Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons, Dialogs, DialogRes;
|
LResources, Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons, Dialogs, DialogRes;
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +25,8 @@ type
|
|||||||
/// the Task Dialog structure which created the form
|
/// the Task Dialog structure which created the form
|
||||||
FDlg: TTaskDialog;
|
FDlg: TTaskDialog;
|
||||||
FVerifyChecked: Boolean;
|
FVerifyChecked: Boolean;
|
||||||
|
Timer: TTimer;
|
||||||
|
TimerStartTime: TTime;
|
||||||
RadioButtonArray: array of TRadioButton;
|
RadioButtonArray: array of TRadioButton;
|
||||||
|
|
||||||
//CustomButtons, Radios: TStringList;
|
//CustomButtons, Radios: TStringList;
|
||||||
@ -53,6 +55,9 @@ type
|
|||||||
function AddLabel(const AText: string; BigFont: boolean; var X, Y: Integer; AFontHeight, AWidth: Integer; APArent: TWinControl): TLabel;
|
function AddLabel(const AText: string; BigFont: boolean; var X, Y: Integer; AFontHeight, AWidth: Integer; APArent: TWinControl): TLabel;
|
||||||
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 OnTimer(Sender: TObject);
|
||||||
|
procedure SetupTimer;
|
||||||
|
procedure ResetTimer;
|
||||||
|
|
||||||
procedure DoDialogConstructed;
|
procedure DoDialogConstructed;
|
||||||
procedure DoDialogCreated;
|
procedure DoDialogCreated;
|
||||||
@ -651,6 +656,41 @@ begin
|
|||||||
inc(Y,42);
|
inc(Y,42);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLCLTaskDialog.OnTimer(Sender: TObject);
|
||||||
|
var
|
||||||
|
AResetTimer: Boolean;
|
||||||
|
MSecs: Cardinal;
|
||||||
|
MSecs64: Int64;
|
||||||
|
begin
|
||||||
|
if Assigned(FDlg.OnTimer) then
|
||||||
|
begin
|
||||||
|
MSecs64 := MilliSecondsBetween(Now, TimerStartTime);
|
||||||
|
{$PUSH}{$R-}
|
||||||
|
MSecs := MSecs64;
|
||||||
|
{$POP}
|
||||||
|
AResetTimer := False;
|
||||||
|
FDlg.OnTimer(FDlg, MSecs, AResetTimer);
|
||||||
|
if AResetTimer then
|
||||||
|
ResetTimer;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLCLTaskDialog.SetupTimer;
|
||||||
|
begin
|
||||||
|
Timer := TTimer.Create(Self);
|
||||||
|
Timer.Interval := 200; //source: https://learn.microsoft.com/en-us/windows/win32/controls/tdn-timer
|
||||||
|
Timer.OnTimer := @OnTimer;
|
||||||
|
TimerStartTime := Now;
|
||||||
|
Timer.Enabled := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLCLTaskDialog.ResetTimer;
|
||||||
|
begin
|
||||||
|
Timer.Enabled := False;
|
||||||
|
TimerStartTime := Now;
|
||||||
|
Timer.Enabled := True;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLCLTaskDialog.DoDialogConstructed;
|
procedure TLCLTaskDialog.DoDialogConstructed;
|
||||||
begin
|
begin
|
||||||
if Assigned(FDlg.OnDialogConstructed) then
|
if Assigned(FDlg.OnDialogConstructed) then
|
||||||
@ -834,6 +874,9 @@ begin
|
|||||||
AddFooter(X, Y, XB, FontHeight, aWidth, CurrParent);
|
AddFooter(X, Y, XB, FontHeight, aWidth, CurrParent);
|
||||||
|
|
||||||
ClientHeight := Y;
|
ClientHeight := Y;
|
||||||
|
|
||||||
|
if (tfCallBackTimer in FDlg.Flags) then
|
||||||
|
SetupTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLCLTaskDialog.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TLCLTaskDialog.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
Loading…
Reference in New Issue
Block a user