TTaskDialog: partially implemented TTaskDialogProgressBar.Initialize.

This commit is contained in:
Bart 2023-08-23 15:23:38 +02:00
parent d556038c01
commit 8a60ec04de
3 changed files with 69 additions and 1 deletions

View File

@ -639,8 +639,18 @@ type
{ TTaskDialogProgressBar }
const
PBST_NORMAL = $0001;
PBST_ERROR = $0002;
PBST_PAUSED = $0003;
Type
TTaskDialogProgressBar = class(TPersistent)
private
const
ProgressBarStateValues: array[TProgressBarState] of Integer = (PBST_NORMAL,PBST_PAUSED,PBST_ERROR);
private
Dlg: TCustomTaskDialog;
FMarqueeSpeed: Cardinal;
FMax: Integer;

View File

@ -120,10 +120,50 @@ end;
procedure TTaskDialogProgressBar.Initialize;
//this should be invoked as soon as the dialog has been instatiated (so Dlg.Handle <> 0),
//so probably in Dlg.DoOnConstructed??
var
Res: LRESULT;
Err: Integer;
IsMarquee: BOOL;
begin
//ToDo:
// send TDM_SET_MARQUEE_PROGRESS_BAR to Dlg (differentiates between "normal" and marguee)
// send range, position and state to dialog.
if (Dlg.Handle <> 0) and (Dlg.Flags * [tfShowProgressBar,tfShowMarqueeProgressBar] <> []) then
begin
IsMarquee := (tfShowMarqueeProgressBar in Dlg.Flags);
writeln('TTaskDialogProgressBar.Initialize: IsMarquee=',IsMarquee);
//wParam = 0 (nonMarque) wParam != 0 (Marquee), lParam must be 0
//if Both Flags are set, Windows seems to intepret this a Marquee
Res := SendMessage(Dlg.Handle, TDM_SET_MARQUEE_PROGRESS_BAR, WPARAM(IsMarquee), 0); //Result is ignored
writeln('TTaskDialogProgressBar.Initialize: TDM_SET_MARQUEE_PROGRESS_BAR: LResult=',PtrInt(Res));
if not IsMarquee then
begin
//wParam must be 0, lParam = MAKELPARAM(nMinRange, nMaxRange)
Res := SendMessage(Dlg.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(FMin, FMax)); //Zero iindicates failure
debugln(['TTaskDialogProgressBar.Initialize: TDM_SET_PROGRESS_BAR_RANGE: LResult=',PtrInt(Res)]);
if (Res = 0) then
begin
Err := GetLastOSError;
debugln(['Err=',Err,': ',SysErrorMessage(Err)]);
end;
end//Not IsMarquee
else
begin //IsMarquee
end;
//wParam = new progress state, lParam must be 0
Res := SendMessage(Dlg.Handle, TDM_SET_PROGRESS_BAR_STATE, WPARAM(ProgressBarStateValues[FState]), 0);
debugln(['TTaskDialogProgressBar.Initialize: TDM_SET_PROGRESS_BAR_STATE: LResult=',PtrInt(Res)]); //Zero iindicates failure
if (Res = 0) then
begin
Err := GetLastOSError;
debugln(['Err=',Err,': ',SysErrorMessage(Err)]);
end;
end;
end;
{ TTaskDialogRadioButtonItem }
@ -255,9 +295,9 @@ end;
procedure TCustomTaskDialog.DoOnDialogConstructed;
begin
FProgressBar.Initialize;
if Assigned(FOnDialogConstructed) then
FOnDialogConstructed(Self);
FProgressBar.Initialize;
end;
procedure TCustomTaskDialog.DoOnDialogCreated;

View File

@ -239,6 +239,24 @@ const
LM_PASTE = $0302;
LM_CLEAR = $0303;
// _TASKDIALOG_MESSAGES enum
TDM_NAVIGATE_PAGE = LM_USER+101;
TDM_CLICK_BUTTON = LM_USER+102; // wParam = Button ID
TDM_SET_MARQUEE_PROGRESS_BAR = LM_USER+103; // wParam = 0 (nonMarque) wParam != 0 (Marquee)
TDM_SET_PROGRESS_BAR_STATE = LM_USER+104; // wParam = new progress state
TDM_SET_PROGRESS_BAR_RANGE = LM_USER+105; // lParam = MAKELPARAM(nMinRange, nMaxRange)
TDM_SET_PROGRESS_BAR_POS = LM_USER+106; // wParam = new position
TDM_SET_PROGRESS_BAR_MARQUEE = LM_USER+107; // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
TDM_SET_ELEMENT_TEXT = LM_USER+108; // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
TDM_CLICK_RADIO_BUTTON = LM_USER+110; // wParam = Radio Button ID
TDM_ENABLE_BUTTON = LM_USER+111; // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
TDM_ENABLE_RADIO_BUTTON = LM_USER+112; // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
TDM_CLICK_VERIFICATION = LM_USER+113; // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
TDM_UPDATE_ELEMENT_TEXT = LM_USER+114; // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = LM_USER+115; // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
TDM_UPDATE_ICON = LM_USER+116; // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
{$I controlconsts.inc}
//-------------