• R/O
  • SSH
  • HTTPS

akdf: Commit


Commit MetaInfo

Revision582 (tree)
Time2022-07-03 03:43:14
Authorderekwildstar

Log Message

Boa parte de TKRKTaskDialog foi implementada e ao mesmo tempo compatibilizada com o Delphi 2006.
Não foram gerados os projetos de todos os Delphi, ao invés disso apenas o projeto do Delphi 2006 foi alterado manualmente

Change Summary

Incremental Difference

--- trunk/rtp/prj/Delphi 10 (Delphi 2006)/KRKLib.dpk (revision 581)
+++ trunk/rtp/prj/Delphi 10 (Delphi 2006)/KRKLib.dpk (revision 582)
@@ -38,7 +38,9 @@
3838 dsnap,
3939 dclstd,
4040 vclie,
41- webdsnap;
41+ webdsnap,
42+ vcl,
43+ rtl;
4244
4345 contains
4446 crtl,
@@ -160,6 +162,8 @@
160162 KRK.Network.WS2Def in '..\..\src\Network\KRK.Network.WS2Def.pas',
161163 KRK.Network.WinSock2 in '..\..\src\Network\KRK.Network.WinSock2.pas',
162164 KRK.Network.WS2TcpIp in '..\..\src\Network\KRK.Network.WS2TcpIp.pas',
163- KRK.Rtl.Win.CommCtrl in '..\..\src\Rtl\Win\KRK.Rtl.Win.CommCtrl.pas';
165+ KRK.Rtl.Win.CommCtrl in '..\..\src\Rtl\Win\KRK.Rtl.Win.CommCtrl.pas',
166+ KRK.Vcl.Dialogs in '..\..\src\Vcl\KRK.Vcl.Dialogs.pas',
167+ KRK.Vcl.Consts in '..\..\src\Vcl\KRK.Vcl.Consts.pas';
164168
165169 end.
--- trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dpk (revision 581)
+++ trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dpk (revision 582)
@@ -162,7 +162,8 @@
162162 KRK.Network.WinSock2 in '..\..\src\Network\KRK.Network.WinSock2.pas',
163163 KRK.Network.WS2TcpIp in '..\..\src\Network\KRK.Network.WS2TcpIp.pas',
164164 KRK.Rtl.Win.CommCtrl in '..\..\src\Rtl\Win\KRK.Rtl.Win.CommCtrl.pas',
165- KRK.Vcl.Dialogs in '..\..\src\Vcl\KRK.Vcl.Dialogs.pas';
165+ KRK.Vcl.Dialogs in '..\..\src\Vcl\KRK.Vcl.Dialogs.pas',
166+ KRK.Vcl.Consts in '..\..\src\Vcl\KRK.Vcl.Consts.pas';
166167
167168 end.
168169
--- trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dproj (revision 581)
+++ trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dproj (revision 582)
@@ -187,6 +187,7 @@
187187 <DCCReference Include="..\..\src\Network\KRK.Network.WS2TcpIp.pas"/>
188188 <DCCReference Include="..\..\src\Rtl\Win\KRK.Rtl.Win.CommCtrl.pas"/>
189189 <DCCReference Include="..\..\src\Vcl\KRK.Vcl.Dialogs.pas"/>
190+ <DCCReference Include="..\..\src\Vcl\KRK.Vcl.Consts.pas"/>
190191 <BuildConfiguration Include="Base">
191192 <Key>Base</Key>
192193 </BuildConfiguration>
--- trunk/rtp/src/Rtl/Win/KRK.Rtl.Win.CommCtrl.pas (revision 581)
+++ trunk/rtp/src/Rtl/Win/KRK.Rtl.Win.CommCtrl.pas (revision 582)
@@ -455,8 +455,38 @@
455455 property OnRegisterToolTip;
456456 end;
457457
458+{$IF RTLVersion = 18} { Delphi 2006 }
459+//{$ALIGN 1} não sei se isso é necessário, acho que não é
460+type
461+ TASKDIALOG_BUTTON = record
462+ nButtonID: Integer;
463+ pszButtonText: LPCWSTR;
464+ end;
465+ PTaskDialogButton = ^TTaskDialogButton;
466+ TTaskDialogButton = TASKDIALOG_BUTTON;
467+{$IFEND}
468+
458469 const
459-{$IF RTLVersion <= 18} { Delphi 2006 }
470+{$IF RTLVersion = 18} { Delphi 2006 }
471+ { Progress Bar Status }
472+ PBST_NORMAL = 1;
473+ PBST_ERROR = 2;
474+ PBST_PAUSED = 3;
475+
476+ { Task Dialog Messages }
477+ TDM_CLICK_BUTTON = WM_USER+102; // wParam = Button ID
478+ TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103; // wParam = 0 (nonMarque) wParam != 0 (Marquee)
479+ TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104; // wParam = new progress state
480+ TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105; // lParam = MAKELPARAM(nMinRange, nMaxRange)
481+ TDM_SET_PROGRESS_BAR_POS = WM_USER + 106; // wParam = new position
482+ TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107; // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
483+ TDM_CLICK_RADIO_BUTTON = WM_USER + 110; // wParam = Radio Button ID
484+ TDM_ENABLE_BUTTON = WM_USER + 111; // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
485+ TDM_ENABLE_RADIO_BUTTON = WM_USER + 112; // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
486+ TDM_CLICK_VERIFICATION = WM_USER + 113; // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
487+ TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115; // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
488+
489+
460490 TOOLTIPS_CLASS = 'tooltips_class32';
461491 MAX_LINKID_TEXT = 48;
462492 L_MAX_URL_LENGTH = 2048 + 32 + length('://') + 1;
--- trunk/rtp/src/Vcl/KRK.Vcl.ComCtrls.pas (revision 581)
+++ trunk/rtp/src/Vcl/KRK.Vcl.ComCtrls.pas (revision 582)
@@ -13,6 +13,9 @@
1313 , Classes;
1414
1515 type
16+{$IF CompilerVersion = 18} { Delphi 2006 }
17+ TProgressBarState = (pbsNormal, pbsError, pbsPaused);
18+{$IFEND}
1619 TCustomKRKPageControl = class;
1720
1821 TKRKTabSheet = class(TWinControl)
--- trunk/rtp/src/Vcl/KRK.Vcl.Consts.pas (nonexistent)
+++ trunk/rtp/src/Vcl/KRK.Vcl.Consts.pas (revision 582)
@@ -0,0 +1,14 @@
1+unit KRK.Vcl.Consts;
2+{$IF CompilerVersion >= 25}{$LEGACYIFEND ON}{$IFEND} { Delphi XE4 }
3+interface
4+
5+{$IF RTLVersion = 18} { Delphi 2006 }
6+resourcestring
7+ STaskDlgRadioButtonCaption = 'RadioButton%d';
8+ STaskDlgButtonCaption = 'Button%d';
9+ SInvalidTaskDlgButtonCaption = 'Caption cannot be empty';
10+{$IFEND}
11+
12+implementation
13+
14+end.
--- trunk/rtp/src/Vcl/KRK.Vcl.Dialogs.pas (revision 581)
+++ trunk/rtp/src/Vcl/KRK.Vcl.Dialogs.pas (revision 582)
@@ -2,227 +2,243 @@
22
33 interface
44
5-//uses
6-// ComCtrls, Classes, Controls, Windows, CommCtrl, Graphics, SysUtils;
7-//
8-//{ O componente TKRKTaskDialog é um wrapper em volta da função de API
9-//TaskDialogIndirect que permite a criação de caixas de mensagem altamente
10-//customizáveis. Este componente foi inteiramente baseado (praticamente uma cópia)
11-//do componente oficial TTaskDialog existente no Delphi Rio e provavelmente em
12-//alguns Delphis anteriores, pois este componente existe na paleta "Vista Dialogs"
13-//e portanto ele deve estar disponível no Delphi que surgiu logo após o Windows
14-//Vista. Criei o componente TKRKTaskDialog porque o componente original não lidava
15-//com estilos depreciados do Windows Vista, estilos estes que ainda estão
16-//disponíveis (ao menos no Windows 10) e porque eu queria usar este componente em
17-//Delphis mais antigos (Delphi 2006 por exemplo). Apesar de eu ter dito que era
18-//praticamente uma cópia, entretanto, este componente está sendo adaptado para
19-//funcionar em versões anteriores do Delphi. Houve, pois, um grande trabalho de
20-//refatoração e ajustes }
21-//
22-//const
23-// tdiNone = 0;
24-// tdiWarning = 1;
25-// tdiError = 2;
26-// tdiInformation = 3;
27-// tdiShield = 4;
28-// tdiShieldHeadBlue = 5;
29-// tdiShieldHeadWarning = 6;
30-// tdiShieldHeadError = 7;
31-// tdiShieldHeadOk = 8;
32-// tdiShieldHeadGreen = 9;
33-//
34-//type
35-// TCustomKRKTaskDialog = class;
36-//
37-// TKRKTaskDialogFlag = (tfEnableHyperlinks, tfUseHiconMain, tfUseHiconFooter,
38-// tfAllowDialogCancellation, tfUseCommandLinks,
39-// tfUseCommandLinksNoIcon, tfExpandFooterArea,
40-// tfExpandedByDefault, tfVerificationFlagChecked,
41-// tfShowProgressBar, tfShowMarqueeProgressBar,
42-// tfCallbackTimer, tfPositionRelativeToWindow,
43-// tfRtlLayout, tfNoDefaultRadioButton, tfCanBeMinimized,
44-// tfSizeToContent);
45-//
46-// TKRKTaskDialogFlags = set of TKRKTaskDialogFlag;
47-//
48-// TKRKTaskDialogCommonButton = (tcbOk, tcbYes, tcbNo, tcbCancel, tcbRetry,
49-// tcbClose);
50-//
51-// TKRKTaskDialogCommonButtons = set of TKRKTaskDialogCommonButton;
52-//
53-// // Os ícones da caixa de diálogo de tarefas são identificados por números cuja
54-// // interpretação varia. Estes números podem tanto ser HICON quanto ponteiros
55-// // PCWSTR para ícones padronizados. Apesar de PCWSTR (PWideChar) normalmente
56-// // ser usado para representar strings, aqui o número informado neste ponteiro
57-// // é usado para indicar o ícone padronizado a ser exibido.
58-// TKRKTaskDialogIcon = Low(Integer)..High(Integer);
59-//
60-// TProgressBarState = ComCtrls.TProgressBarState; // for compatibility
61-//
62-// TKRKTaskDialogProgressBar = class(TPersistent)
63-// private
64-// FClient: TCustomKRKTaskDialog;
65-// FMarqueeSpeed: Cardinal;
66-// FMax: Integer;
67-// FMin: Integer;
68-// FPosition: Integer;
69-// FState: TProgressBarState;
70-//
71-// procedure SetMarqueeSpeed(const AValue: Cardinal);
72-// procedure SetMax(const AValue: Integer);
73-// procedure SetMin(const AValue: Integer);
74-// procedure SetPosition(const AValue: Integer);
75-// procedure SetState(const AValue: TProgressBarState);
76-// public
77-// constructor Create(AClient: TCustomKRKTaskDialog);
78-//
79-// procedure Initialize;
80-// published
81-// property MarqueeSpeed: Cardinal read FMarqueeSpeed write SetMarqueeSpeed default 0;
82-// property Max: Integer read FMax write SetMax default 100;
83-// property Min: Integer read FMin write SetMin default 0;
84-// property Position: Integer read FPosition write SetPosition default 0;
85-// property State: TProgressBarState read FState write SetState default pbsNormal;
86-// end;
87-//
88-// // Tanto botões comuns como botões de rádio possuem um mesmo conjunto de
89-// // propriedades, por isso esta classe existe e serve como classe mãe tanto
90-// // para TKRKTaskDialogButtonItem como TKRKTaskDialogRadioButtonItem
91-// TKRKTaskDialogBaseButtonItem = class(TCollectionItem)
92-// private
93-// FCaption: string;
94-// FClient: TCustomKRKTaskDialog;
95-// FEnabled: Boolean;
96-// FModalResult: TModalResult;
97-// FTextWStr: LPCWSTR;
98-// function GetDefault: Boolean;
99-// function GetTextWStr: LPCWSTR;
100-// procedure SetCaption(const Value: string);
101-// procedure SetDefault(const Value: Boolean);
102-// procedure SetEnabled(const Value: Boolean);
103-// protected
104-// procedure DoButtonClick; virtual;
105-// procedure DoSetEnabled; virtual;
106-// function GetButtonText: string; virtual;
107-// property Client: TCustomKRKTaskDialog read FClient;
108-// function GetDisplayName: string; override;
109-// public
110-// constructor Create(Collection: TCollection); override;
111-// destructor Destroy; override;
112-// procedure Click;
113-// procedure SetInitialState; virtual;
114-// property ModalResult: TModalResult read FModalResult write FModalResult;
115-// property TextWStr: LPCWSTR read GetTextWStr;
116-// published
117-// property Caption: string read FCaption write SetCaption;
118-// property Default: Boolean read GetDefault write SetDefault default False;
119-// property Enabled: Boolean read FEnabled write SetEnabled default True;
120-// end;
121-//
122-// TKRKTaskDialogButtonItem = class(TKRKTaskDialogBaseButtonItem)
123-// private
124-// FCommandLinkHint: string;
125-// FElevationRequired: Boolean;
126-// procedure DoSetElevationRequired;
127-// procedure SetElevationRequired(const Value: Boolean);
128-// protected
129-// function GetButtonText: string; override;
130-// public
131-// constructor Create(Collection: TCollection); override;
132-// procedure SetInitialState; override;
133-// published
134-// property CommandLinkHint: string read FCommandLinkHint write FCommandLinkHint;
135-// property ElevationRequired: Boolean read FElevationRequired write SetElevationRequired default False;
136-// property ModalResult;
137-// end;
138-//
139-// TKRKTaskDialogRadioButtonItem = class(TKRKTaskDialogBaseButtonItem)
140-// protected
141-// procedure DoButtonClick; override;
142-// procedure DoSetEnabled; override;
143-// public
144-// constructor Create(Collection: TCollection); override;
145-// end;
146-//
147-// TKRKTaskDialogButtonList = array of TTaskDialogButton;
148-//
149-// TKRKTaskDialogButtons = class;
150-//
151-// TKRKTaskDialogButtonsEnumerator = class
152-// private
153-// FIndex: Integer;
154-// FCollection: TKRKTaskDialogButtons;
155-// public
156-// constructor Create(ACollection: TKRKTaskDialogButtons);
157-// function GetCurrent: TKRKTaskDialogBaseButtonItem;
158-// function MoveNext: Boolean;
159-// property Current: TKRKTaskDialogBaseButtonItem read GetCurrent;
160-// end;
161-//
162-// TKRKTaskDialogButtons = class(TOwnedCollection)
163-// private
164-// FButtonList: TKRKTaskDialogButtonList;
165-// FButtonListPtr: PTaskDialogButton;
166-// FDefaultButton: TKRKTaskDialogBaseButtonItem;
167-// function GetItem(Index: Integer): TKRKTaskDialogBaseButtonItem;
168-// procedure SetDefaultButton(const Value: TKRKTaskDialogBaseButtonItem);
169-// procedure SetItem(Index: Integer; const Value: TKRKTaskDialogBaseButtonItem);
170-// public
171-// destructor Destroy; override;
172-// function Add: TKRKTaskDialogBaseButtonItem;
173-// function Buttons: PTaskDialogButton;
174-// function FindButton(AModalResult: TModalResult): TKRKTaskDialogBaseButtonItem;
175-// function GetEnumerator: TKRKTaskDialogButtonsEnumerator;
176-// procedure SetInitialState; dynamic;
177-// property DefaultButton: TKRKTaskDialogBaseButtonItem read FDefaultButton write SetDefaultButton;
178-// property Items[Index: Integer]: TKRKTaskDialogBaseButtonItem read GetItem write SetItem; default;
179-// end;
180-//
181-// TKRKTaskDialogClickEvent = procedure(Sender: TObject; ModalResult: TModalResult; var CanClose: Boolean) of object;
182-// TKRKTaskDialogTimerEvent = procedure(Sender: TObject; TickCount: Cardinal; var Reset: Boolean) of object;
183-//
184-// TCustomKRKTaskDialog = class(TComponent)
185-// private
186-// FButton: TKRKTaskDialogButtonItem;
187-// FButtons: TKRKTaskDialogButtons;
188-// FCaption: string;
189-// FCommonButtons: TKRKTaskDialogCommonButtons;
190-// FCustomFooterIcon: TIcon;
191-// FCustomMainIcon: TIcon;
192-// FDefaultButton: TKRKTaskDialogCommonButton;
193-// FExpandButtonCaption: string;
194-// FExpandedControlText: String;
195-// FExpanded: Boolean;
196-// FExpandedText: string;
197-// FFlags: TKRKTaskDialogFlags;
198-// FFooterIcon: TKRKTaskDialogIcon;
199-// FFooterText: string;
200-// FHandle: HWND;
201-// FHelpContext: Integer;
202-// FMainIcon: TKRKTaskDialogIcon;
203-// FModalResult: TModalResult;
204-// FProgressBar: TKRKTaskDialogProgressBar;
205-// FRadioButton: TKRKTaskDialogRadioButtonItem;
206-// FRadioButtons: TKRKTaskDialogButtons;
207-// FText: string;
208-// FTitle: string;
209-// FURL: string;
210-// FVerificationText: string;
211-// FOnButtonClicked: TKRKTaskDialogClickEvent;
212-// FOnDialogConstructed: TNotifyEvent;
213-// FOnDialogCreated: TNotifyEvent;
214-// FOnDialogDestroyed: TNotifyEvent;
215-// FOnExpanded: TNotifyEvent;
216-// FOnHyperlinkClicked: TNotifyEvent;
217-// FOnNavigated: TNotifyEvent;
218-// FOnRadioButtonClicked: TNotifyEvent;
219-// FOnTimer: TKRKTaskDialogTimerEvent;
220-// FOnVerificationClicked: TNotifyEvent;
5+uses
6+ ComCtrls, KRK.Vcl.ComCtrls, Classes, Controls, Windows, CommCtrl,
7+ KRK.Rtl.Win.CommCtrl, Graphics, SysUtils;
8+
9+{ O componente TKRKTaskDialog é um wrapper em volta da função de API
10+TaskDialogIndirect que permite a criação de caixas de mensagem altamente
11+customizáveis. Este componente foi inteiramente baseado (praticamente uma cópia)
12+do componente oficial TTaskDialog existente no Delphi Rio e provavelmente em
13+alguns Delphis anteriores, pois este componente existe na paleta "Vista Dialogs"
14+e portanto ele deve estar disponível no Delphi que surgiu logo após o Windows
15+Vista. Criei o componente TKRKTaskDialog porque o componente original não lidava
16+com estilos depreciados do Windows Vista, estilos estes que ainda estão
17+disponíveis (ao menos no Windows 10) e porque eu queria usar este componente em
18+Delphis mais antigos (Delphi 2006 por exemplo). Apesar de eu ter dito que era
19+praticamente uma cópia, entretanto, este componente está sendo adaptado para
20+funcionar em versões anteriores do Delphi. Houve, pois, um grande trabalho de
21+refatoração e ajustes }
22+
23+// Constantes criadas desta forma podem ser usadas em propriedades do tipo
24+// integer, pois o Delphi sabe que elas representam números. Isso não é
25+// novidade, visto que já era possível usar MaxInt, e outras constantes
26+// similares em propriedades integer. Acredito que isso valha também para
27+// constantes de outros tipos, em propriedades de tipos correspondentes, por
28+// exemplo, Single e Double, mas não tenho certeza
29+const
30+ tdiNone = 0;
31+ tdiWarning = 1;
32+ tdiError = 2;
33+ tdiInformation = 3;
34+ tdiShield = 4;
35+ tdiShieldHeadBlue = 5;
36+ tdiShieldHeadWarning = 6;
37+ tdiShieldHeadError = 7;
38+ tdiShieldHeadOk = 8;
39+ tdiShieldHeadGreen = 9;
40+
41+type
42+ TCustomKRKTaskDialog = class;
43+
44+ TKRKTaskDialogFlag = (tfEnableHyperlinks, tfUseHiconMain, tfUseHiconFooter,
45+ tfAllowDialogCancellation, tfUseCommandLinks,
46+ tfUseCommandLinksNoIcon, tfExpandFooterArea,
47+ tfExpandedByDefault, tfVerificationFlagChecked,
48+ tfShowProgressBar, tfShowMarqueeProgressBar,
49+ tfCallbackTimer, tfPositionRelativeToWindow,
50+ tfRtlLayout, tfNoDefaultRadioButton, tfCanBeMinimized,
51+ tfSizeToContent);
52+
53+ TKRKTaskDialogFlags = set of TKRKTaskDialogFlag;
54+
55+ TKRKTaskDialogCommonButton = (tcbOk, tcbYes, tcbNo, tcbCancel, tcbRetry,
56+ tcbClose);
57+
58+ TKRKTaskDialogCommonButtons = set of TKRKTaskDialogCommonButton;
59+
60+ // Os ícones da caixa de diálogo de tarefas são identificados por números cuja
61+ // interpretação varia. Estes números podem tanto ser HICON quanto ponteiros
62+ // PCWSTR para ícones padronizados. Apesar de PCWSTR (PWideChar) normalmente
63+ // ser usado para representar strings, aqui o número informado neste ponteiro
64+ // é usado para indicar o ícone padronizado a ser exibido.
65+ TKRKTaskDialogIcon = Low(Integer)..High(Integer);
66+
67+ TProgressBarState = {$IF CompilerVersion = 18}KRK.Vcl.ComCtrls{$ELSE}ComCtrls{$IFEND}.TProgressBarState; // for compatibility
68+
69+ TKRKTaskDialogProgressBar = class(TPersistent)
70+ private
71+ FClient: TCustomKRKTaskDialog;
72+ FMarqueeSpeed: Cardinal;
73+ FMax: Integer;
74+ FMin: Integer;
75+ FPosition: Integer;
76+ FState: TProgressBarState;
77+
78+ procedure SetMarqueeSpeed(const AValue: Cardinal);
79+ procedure SetMax(const AValue: Integer);
80+ procedure SetMin(const AValue: Integer);
81+ procedure SetPosition(const AValue: Integer);
82+ procedure SetState(const AValue: TProgressBarState);
83+ public
84+ constructor Create(AClient: TCustomKRKTaskDialog);
85+
86+ procedure Initialize;
87+ published
88+ property MarqueeSpeed: Cardinal read FMarqueeSpeed write SetMarqueeSpeed default 0;
89+ property Max: Integer read FMax write SetMax default 100;
90+ property Min: Integer read FMin write SetMin default 0;
91+ property Position: Integer read FPosition write SetPosition default 0;
92+ property State: TProgressBarState read FState write SetState default pbsNormal;
93+ end;
94+
95+ // Tanto botões comuns como botões de rádio possuem um mesmo conjunto de
96+ // propriedades, por isso esta classe existe e serve como classe mãe tanto
97+ // para TKRKTaskDialogButtonItem como TKRKTaskDialogRadioButtonItem
98+ TKRKTaskDialogBaseButtonItem = class(TCollectionItem)
99+ private
100+ FCaption: string;
101+ FClient: TCustomKRKTaskDialog;
102+ FEnabled: Boolean;
103+ FModalResult: TModalResult;
104+ FTextWStr: LPCWSTR;
105+
106+ function GetDefault: Boolean;
107+ function GetTextWStr: LPCWSTR;
108+ procedure SetCaption(const AValue: string);
109+ procedure SetDefault(const AValue: Boolean);
110+ procedure SetEnabled(const AValue: Boolean);
111+ protected
112+ procedure DoButtonClick; virtual;
113+ procedure DoSetEnabled; virtual;
114+ function GetButtonText: string; virtual;
115+ function GetDisplayName: string; override;
116+
117+ property Client: TCustomKRKTaskDialog read FClient;
118+ public
119+ constructor Create(ACollection: TCollection); override;
120+ destructor Destroy; override;
121+
122+ procedure Click;
123+ procedure SetInitialState; virtual;
124+ property ModalResult: TModalResult read FModalResult write FModalResult;
125+ property TextWStr: LPCWSTR read GetTextWStr;
126+ published
127+ property Caption: string read FCaption write SetCaption;
128+ property Default: Boolean read GetDefault write SetDefault default False;
129+ property Enabled: Boolean read FEnabled write SetEnabled default True;
130+ end;
131+
132+ TKRKTaskDialogButtonItem = class(TKRKTaskDialogBaseButtonItem)
133+ private
134+ FCommandLinkHint: string;
135+ FElevationRequired: Boolean;
136+
137+ procedure DoSetElevationRequired;
138+ procedure SetElevationRequired(const AValue: Boolean);
139+ protected
140+ function GetButtonText: string; override;
141+ public
142+ constructor Create(ACollection: TCollection); override;
143+
144+ procedure SetInitialState; override;
145+ published
146+ property CommandLinkHint: string read FCommandLinkHint write FCommandLinkHint;
147+ property ElevationRequired: Boolean read FElevationRequired write SetElevationRequired default False;
148+ property ModalResult;
149+ end;
150+
151+ TKRKTaskDialogRadioButtonItem = class(TKRKTaskDialogBaseButtonItem)
152+ protected
153+ procedure DoButtonClick; override;
154+ procedure DoSetEnabled; override;
155+ public
156+ constructor Create(ACollection: TCollection); override;
157+ end;
158+
159+ TKRKTaskDialogButtonList = array of TTaskDialogButton;
160+
161+ TKRKTaskDialogButtons = class;
162+
163+ TKRKTaskDialogButtonsEnumerator = class
164+ private
165+ FIndex: Integer;
166+ FCollection: TKRKTaskDialogButtons;
167+ public
168+ constructor Create(ACollection: TKRKTaskDialogButtons);
169+
170+ function GetCurrent: TKRKTaskDialogBaseButtonItem;
171+ function MoveNext: Boolean;
172+
173+ property Current: TKRKTaskDialogBaseButtonItem read GetCurrent;
174+ end;
175+
176+ TKRKTaskDialogButtons = class(TOwnedCollection)
177+ private
178+ FButtonList: TKRKTaskDialogButtonList;
179+ FButtonListPtr: PTaskDialogButton;
180+ FDefaultButton: TKRKTaskDialogBaseButtonItem;
181+
182+ function GetItem(AIndex: Integer): TKRKTaskDialogBaseButtonItem;
183+ procedure SetDefaultButton(const AValue: TKRKTaskDialogBaseButtonItem);
184+ procedure SetItem(AIndex: Integer; const AValue: TKRKTaskDialogBaseButtonItem);
185+ public
186+ destructor Destroy; override;
187+ function Add: TKRKTaskDialogBaseButtonItem;
188+ function Buttons: PTaskDialogButton;
189+ function FindButton(AModalResult: TModalResult): TKRKTaskDialogBaseButtonItem;
190+ function GetEnumerator: TKRKTaskDialogButtonsEnumerator;
191+ procedure SetInitialState; dynamic;
192+
193+ property DefaultButton: TKRKTaskDialogBaseButtonItem read FDefaultButton write SetDefaultButton;
194+ property Items[Index: Integer]: TKRKTaskDialogBaseButtonItem read GetItem write SetItem; default;
195+ end;
196+
197+ TKRKTaskDialogClickEvent = procedure(ASender: TObject; AModalResult: TModalResult; var ACanClose: Boolean) of object;
198+ TKRKTaskDialogTimerEvent = procedure(ASender: TObject; ATickCount: Cardinal; var AReset: Boolean) of object;
199+
200+ TCustomKRKTaskDialog = class(TComponent)
201+ private
202+ FButton: TKRKTaskDialogButtonItem;
203+ FButtons: TKRKTaskDialogButtons;
204+ FCaption: string;
205+ FCommonButtons: TKRKTaskDialogCommonButtons;
206+ FCustomFooterIcon: TIcon;
207+ FCustomMainIcon: TIcon;
208+ FDefaultButton: TKRKTaskDialogCommonButton;
209+ FExpandButtonCaption: string;
210+ FExpandedControlText: String;
211+ FExpanded: Boolean;
212+ FExpandedText: string;
213+ FFlags: TKRKTaskDialogFlags;
214+ FFooterIcon: TKRKTaskDialogIcon;
215+ FFooterText: string;
216+ FHandle: HWND;
217+ FHelpContext: Integer;
218+ FMainIcon: TKRKTaskDialogIcon;
219+ FModalResult: TModalResult;
220+ FProgressBar: TKRKTaskDialogProgressBar;
221+ FRadioButton: TKRKTaskDialogRadioButtonItem;
222+ FRadioButtons: TKRKTaskDialogButtons;
223+ FText: string;
224+ FTitle: string;
225+ FURL: string;
226+ FVerificationText: string;
227+ FOnButtonClicked: TKRKTaskDialogClickEvent;
228+ FOnDialogConstructed: TNotifyEvent;
229+ FOnDialogCreated: TNotifyEvent;
230+ FOnDialogDestroyed: TNotifyEvent;
231+ FOnExpanded: TNotifyEvent;
232+ FOnHyperlinkClicked: TNotifyEvent;
233+ FOnNavigated: TNotifyEvent;
234+ FOnRadioButtonClicked: TNotifyEvent;
235+ FOnTimer: TKRKTaskDialogTimerEvent;
236+ FOnVerificationClicked: TNotifyEvent;
221237 // procedure SetButtons(const Value: TKRKTaskDialogButtons);
222238 // procedure SetExpandedText(const Value: string);
223239 // procedure SetFooterIcon(const Value: TKRKTaskDialogIcon);
224240 // procedure SetFooterText(const Value: string);
225-// procedure SetFlags(const Value: TKRKTaskDialogFlags);
241+ procedure SetFlags(const AValue: TKRKTaskDialogFlags);
226242 // procedure SetMainIcon(const Value: TKRKTaskDialogIcon);
227243 // procedure SetRadioButtons(const Value: TKRKTaskDialogButtons);
228244 // procedure SetText(const Value: string);
@@ -229,7 +245,7 @@
229245 // procedure SetTitle(const Value: string);
230246 // procedure SetCustomFooterIcon(const Value: TIcon);
231247 // procedure SetCustomMainIcon(const Value: TIcon);
232-// protected
248+ protected
233249 // function DoExecute(ParentWnd: HWND): Boolean; dynamic;
234250 // procedure DoOnButtonClicked(AModalResult: Integer; var CanClose: Boolean); dynamic;
235251 // procedure DoOnDialogContructed; dynamic;
@@ -243,9 +259,8 @@
243259 // procedure DoOnTimer(TickCount: Cardinal; var Reset: Boolean); dynamic;
244260 // procedure DoOnVerificationClicked(Checked: Boolean); dynamic;
245261 // procedure ShowHelpException(E: Exception); dynamic;
246-// function CallbackProc(hwnd: HWND; msg: UINT; wParam: WPARAM;
247-// lParam: LPARAM; lpRefData: LONG_PTR): HResult; dynamic;
248-// public
262+// function CallbackProc(hwnd: HWND; msg: UINT; wParam: WPARAM; lParam: LPARAM; lpRefData: LONG_PTR): HResult; dynamic;
263+ public
249264 // constructor Create(AOwner: TComponent); override;
250265 // destructor Destroy; override;
251266 // function Execute: Boolean; overload; dynamic;
@@ -261,10 +276,10 @@
261276 // property ExpandedControlText: String read FExpandedControlText write FExpandedControlText;
262277 // property Expanded: Boolean read FExpanded;
263278 // property ExpandedText: string read FExpandedText write SetExpandedText;
264-// property Flags: TKRKTaskDialogFlags read FFlags write SetFlags default [tfAllowDialogCancellation];
279+ property Flags: TKRKTaskDialogFlags read FFlags write SetFlags default [tfAllowDialogCancellation];
265280 // property FooterIcon: TKRKTaskDialogIcon read FFooterIcon write SetFooterIcon default tdiNone;
266281 // property FooterText: string read FFooterText write SetFooterText;
267-// property Handle: HWND read FHandle;
282+ property Handle: HWND read FHandle;
268283 // property HelpContext: Integer read FHelpContext write FHelpContext default 0;
269284 // property MainIcon: TKRKTaskDialogIcon read FMainIcon write SetMainIcon default tdiInformation;
270285 // property ModalResult: TModalResult read FModalResult write FModalResult;
@@ -285,9 +300,9 @@
285300 // property OnRadioButtonClicked: TNotifyEvent read FOnRadioButtonClicked write FOnRadioButtonClicked;
286301 // property OnTimer: TKRKTaskDialogTimerEvent read FOnTimer write FOnTimer;
287302 // property OnVerificationClicked: TNotifyEvent read FOnVerificationClicked write FOnVerificationClicked;
288-// end;
289-//
290-// TKRKTaskDialog = class(TCustomKRKTaskDialog)
303+ end;
304+
305+ TKRKTaskDialog = class(TCustomKRKTaskDialog)
291306 // published
292307 // property Buttons;
293308 // property Caption;
@@ -318,106 +333,389 @@
318333 // property OnRadioButtonClicked;
319334 // property OnTimer;
320335 // property OnVerificationClicked;
321-// end;
336+ end;
322337
323338 implementation
324339
325-//uses
326-// Consts;
327-//
328-//{ TKRKTaskDialogProgressBar }
329-//
330-//constructor TKRKTaskDialogProgressBar.Create(AClient: TCustomKRKTaskDialog);
331-//begin
332-// inherited Create;
333-//
334-// FClient := AClient;
335-// FMax := 100;
336-// FMin := 0;
337-// FPosition := 0;
338-// FMarqueeSpeed := 0;
339-// FState := pbsNormal;
340-//end;
341-//
342-//const
343-// ProgressBarStates: array[TProgressBarState] of Integer = (PBST_NORMAL, PBST_ERROR, PBST_PAUSED);
344-//
345-//procedure TKRKTaskDialogProgressBar.Initialize;
346-//begin
347-// SendMessage(FClient.Handle, TDM_SET_MARQUEE_PROGRESS_BAR, WPARAM(BOOL((tfShowMarqueeProgressBar in FClient.Flags))), 0);
348-//
349-// if (tfShowMarqueeProgressBar in FClient.Flags) then
350-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_MARQUEE, WPARAM(BOOL(True)), FMarqueeSpeed)
351-// else
352-// begin
353-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
354-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_POS, FPosition, 0);
355-// end;
356-//
357-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_STATE, ProgressBarStates[FState], 0);
358-//end;
359-//
360-//procedure TKRKTaskDialogProgressBar.SetMarqueeSpeed(const AValue: Cardinal);
361-//begin
362-// if AValue <> FMarqueeSpeed then
363-// begin
364-// FMarqueeSpeed := AValue;
365-// if (FClient.Handle <> 0) and (tfShowMarqueeProgressBar in FClient.Flags) then
366-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_MARQUEE, WPARAM(BOOL(True)), FMarqueeSpeed);
367-// end;
368-//end;
369-//
370-//procedure TKRKTaskDialogProgressBar.SetMax(const AValue: Integer);
371-//begin
372-// if AValue <> FMax then
373-// begin
374-// if AValue < FMin then
375-// raise EInvalidOperation.CreateFmt(SPropertyOutOfRange, [Classname]);
376-//
377-// FMax := AValue;
378-//
379-// if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
380-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
381-// end;
382-//end;
383-//
384-//procedure TKRKTaskDialogProgressBar.SetMin(const AValue: Integer);
385-//begin
386-// if AValue <> FMin then
387-// begin
388-// if AValue > FMax then
389-// raise EInvalidOperation.CreateFmt(SPropertyOutOfRange, [Classname]);
390-//
391-// FMin := AValue;
392-//
393-// if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
394-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
395-// end;
396-//end;
397-//
398-//procedure TKRKTaskDialogProgressBar.SetPosition(const AValue: Integer);
399-//begin
400-// if AValue <> FPosition then
401-// begin
402-// if (AValue < 0) or (AValue > High(Word)) then
403-// raise Exception.CreateResFmt(@SOutOfRange, [0, High(Word)]);
404-//
405-// FPosition := AValue;
406-//
407-// if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
408-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_POS, FPosition, 0);
409-// end;
410-//end;
411-//
412-//procedure TKRKTaskDialogProgressBar.SetState(const AValue: TProgressBarState);
413-//begin
414-// if AValue <> FState then
415-// begin
416-// FState := AValue;
417-//
418-// if (FClient.Handle <> 0) then
419-// SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_STATE, ProgressBarStates[FState], 0);
420-// end;
421-//end;
340+uses
341+ Consts, KRK.Vcl.Consts, ActiveX, WideStrUtils;
422342
343+{ Funções utilitárias }
344+
345+function AllocCoTaskMemStr(const S: string): LPCWSTR;
346+var
347+ Len: Integer;
348+begin
349+ Len := Length(S);
350+ Result := CoTaskMemAlloc((Len * SizeOf(WideChar)) + SizeOf(WideChar));
351+ Result := WStrPLCopy(Result, S, Len);
352+end;
353+
354+{ TKRKTaskDialogProgressBar }
355+
356+constructor TKRKTaskDialogProgressBar.Create(AClient: TCustomKRKTaskDialog);
357+begin
358+ inherited Create;
359+
360+ FClient := AClient;
361+ FMax := 100;
362+ FMin := 0;
363+ FPosition := 0;
364+ FMarqueeSpeed := 0;
365+ FState := pbsNormal;
366+end;
367+
368+const
369+ ProgressBarStates: array[TProgressBarState] of Integer = (PBST_NORMAL, PBST_ERROR, PBST_PAUSED);
370+
371+procedure TKRKTaskDialogProgressBar.Initialize;
372+begin
373+ SendMessage(FClient.Handle, TDM_SET_MARQUEE_PROGRESS_BAR, WPARAM(BOOL((tfShowMarqueeProgressBar in FClient.Flags))), 0);
374+
375+ if (tfShowMarqueeProgressBar in FClient.Flags) then
376+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_MARQUEE, WPARAM(BOOL(True)), FMarqueeSpeed)
377+ else
378+ begin
379+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
380+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_POS, FPosition, 0);
381+ end;
382+
383+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_STATE, ProgressBarStates[FState], 0);
384+end;
385+
386+procedure TKRKTaskDialogProgressBar.SetMarqueeSpeed(const AValue: Cardinal);
387+begin
388+ if AValue <> FMarqueeSpeed then
389+ begin
390+ FMarqueeSpeed := AValue;
391+ if (FClient.Handle <> 0) and (tfShowMarqueeProgressBar in FClient.Flags) then
392+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_MARQUEE, WPARAM(BOOL(True)), FMarqueeSpeed);
393+ end;
394+end;
395+
396+procedure TKRKTaskDialogProgressBar.SetMax(const AValue: Integer);
397+begin
398+ if AValue <> FMax then
399+ begin
400+ if AValue < FMin then
401+ raise EInvalidOperation.CreateFmt(SPropertyOutOfRange, [Classname]);
402+
403+ FMax := AValue;
404+
405+ if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
406+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
407+ end;
408+end;
409+
410+procedure TKRKTaskDialogProgressBar.SetMin(const AValue: Integer);
411+begin
412+ if AValue <> FMin then
413+ begin
414+ if AValue > FMax then
415+ raise EInvalidOperation.CreateFmt(SPropertyOutOfRange, [Classname]);
416+
417+ FMin := AValue;
418+
419+ if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
420+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_RANGE, 0, MakeLParam(FMin, FMax));
421+ end;
422+end;
423+
424+procedure TKRKTaskDialogProgressBar.SetPosition(const AValue: Integer);
425+begin
426+ if AValue <> FPosition then
427+ begin
428+ if (AValue < 0) or (AValue > High(Word)) then
429+ raise Exception.CreateResFmt(@SOutOfRange, [0, High(Word)]);
430+
431+ FPosition := AValue;
432+
433+ if (FClient.Handle <> 0) and not (tfShowMarqueeProgressBar in FClient.Flags) then
434+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_POS, FPosition, 0);
435+ end;
436+end;
437+
438+procedure TKRKTaskDialogProgressBar.SetState(const AValue: TProgressBarState);
439+begin
440+ if AValue <> FState then
441+ begin
442+ FState := AValue;
443+
444+ if (FClient.Handle <> 0) then
445+ SendMessage(FClient.Handle, TDM_SET_PROGRESS_BAR_STATE, ProgressBarStates[FState], 0);
446+ end;
447+end;
448+
449+{ TCustomKRKTaskDialog }
450+
451+procedure TCustomKRKTaskDialog.SetFlags(const AValue: TKRKTaskDialogFlags);
452+begin
453+ if AValue <> FFlags then
454+ begin
455+ if (tfVerificationFlagChecked in FFlags) <> (tfVerificationFlagChecked in AValue) and (FHandle <> 0) then
456+ SendMessage(FHandle, TDM_CLICK_VERIFICATION, WPARAM((tfVerificationFlagChecked in AValue)), LPARAM(False));
457+
458+ FFlags := AValue;
459+ end;
460+end;
461+
462+{ TKRKTaskDialogBaseButtonItem }
463+
464+procedure TKRKTaskDialogBaseButtonItem.Click;
465+begin
466+ DoButtonClick;
467+end;
468+
469+constructor TKRKTaskDialogBaseButtonItem.Create(ACollection: TCollection);
470+begin
471+ inherited;
472+
473+ FCaption := '';
474+ FClient := TCustomKRKTaskDialog(Collection.Owner);
475+ FEnabled := True;
476+ FModalResult := ID + 100; // Evita conflitos com algumas constantes "mr"
477+ FTextWStr := nil;
478+end;
479+
480+destructor TKRKTaskDialogBaseButtonItem.Destroy;
481+begin
482+ if Assigned(FTextWStr) then
483+ CoTaskMemFree(FTextWStr);
484+
485+ inherited;
486+end;
487+
488+procedure TKRKTaskDialogBaseButtonItem.DoButtonClick;
489+begin
490+ if FClient.Handle <> 0 then
491+ SendMessage(FClient.Handle, TDM_CLICK_BUTTON, FModalResult, 0);
492+end;
493+
494+procedure TKRKTaskDialogBaseButtonItem.DoSetEnabled;
495+begin
496+ if FClient.Handle <> 0 then
497+ SendMessage(FClient.Handle, TDM_ENABLE_BUTTON, FModalResult, LPARAM(FEnabled))
498+end;
499+
500+function TKRKTaskDialogBaseButtonItem.GetButtonText: string;
501+begin
502+ Result := FCaption;
503+end;
504+
505+function TKRKTaskDialogBaseButtonItem.GetDefault: Boolean;
506+begin
507+ Result := TKRKTaskDialogButtons(Collection).DefaultButton = Self;
508+end;
509+
510+function TKRKTaskDialogBaseButtonItem.GetDisplayName: string;
511+begin
512+ Result := FCaption;
513+
514+ if Result = '' then
515+ Result := inherited GetDisplayName;
516+end;
517+
518+function TKRKTaskDialogBaseButtonItem.GetTextWStr: LPCWSTR;
519+var
520+ LText: string;
521+begin
522+ LText := GetButtonText;
523+
524+ if Assigned(FTextWStr) then
525+ CoTaskMemFree(FTextWStr);
526+
527+ FTextWStr := AllocCoTaskMemStr(LText);
528+ Result := FTextWStr;
529+end;
530+
531+procedure TKRKTaskDialogBaseButtonItem.SetCaption(const AValue: string);
532+begin
533+ if AValue <> FCaption then
534+ begin
535+ if AValue = '' then
536+ raise Exception.CreateRes(@SInvalidTaskDlgButtonCaption);
537+
538+ FCaption := AValue;
539+ end;
540+end;
541+
542+procedure TKRKTaskDialogBaseButtonItem.SetDefault(const AValue: Boolean);
543+begin
544+ if AValue then
545+ TKRKTaskDialogButtons(Collection).DefaultButton := Self
546+ else if TKRKTaskDialogButtons(Collection).DefaultButton = Self then
547+ TKRKTaskDialogButtons(Collection).DefaultButton := nil;
548+end;
549+
550+procedure TKRKTaskDialogBaseButtonItem.SetEnabled(const AValue: Boolean);
551+begin
552+ if AValue <> FEnabled then
553+ begin
554+ FEnabled := AValue;
555+ DoSetEnabled;
556+ end;
557+end;
558+
559+procedure TKRKTaskDialogBaseButtonItem.SetInitialState;
560+begin
561+ if not FEnabled then
562+ DoSetEnabled;
563+end;
564+
565+{ TKRKTaskDialogButtons }
566+
567+function TKRKTaskDialogButtons.Add: TKRKTaskDialogBaseButtonItem;
568+begin
569+ Result := TKRKTaskDialogBaseButtonItem(inherited Add);
570+end;
571+
572+function TKRKTaskDialogButtons.Buttons: PTaskDialogButton;
573+var
574+ i: Integer;
575+begin
576+ SetLength(FButtonList, Count);
577+
578+ for i := 0 to Count - 1 do
579+ begin
580+ FButtonList[i].nButtonID := Items[i].ModalResult;
581+ FButtonList[i].pszButtonText := Items[i].TextWStr;
582+ end;
583+
584+ FButtonListPtr := @FButtonList[0];
585+ Result := FButtonListPtr;
586+end;
587+
588+destructor TKRKTaskDialogButtons.Destroy;
589+begin
590+
591+ inherited;
592+end;
593+
594+function TKRKTaskDialogButtons.FindButton(AModalResult: TModalResult): TKRKTaskDialogBaseButtonItem;
595+var
596+ LButton: TKRKTaskDialogBaseButtonItem;
597+begin
598+ Result := nil;
599+
600+ for LButton in Self do
601+ if LButton.ModalResult = AModalResult then
602+ begin
603+ Result := LButton;
604+ Exit;
605+ end;
606+end;
607+
608+function TKRKTaskDialogButtons.GetEnumerator: TKRKTaskDialogButtonsEnumerator;
609+begin
610+ Result := TKRKTaskDialogButtonsEnumerator.Create(Self);
611+end;
612+
613+function TKRKTaskDialogButtons.GetItem(AIndex: Integer): TKRKTaskDialogBaseButtonItem;
614+begin
615+ Result := TKRKTaskDialogBaseButtonItem(inherited GetItem(AIndex));
616+end;
617+
618+procedure TKRKTaskDialogButtons.SetDefaultButton(const AValue: TKRKTaskDialogBaseButtonItem);
619+begin
620+ if AValue <> FDefaultButton then
621+ FDefaultButton := AValue;
622+end;
623+
624+procedure TKRKTaskDialogButtons.SetInitialState;
625+var
626+ LButton: TKRKTaskDialogBaseButtonItem;
627+begin
628+ for LButton in Self do
629+ LButton.SetInitialState;
630+end;
631+
632+procedure TKRKTaskDialogButtons.SetItem(AIndex: Integer; const AValue: TKRKTaskDialogBaseButtonItem);
633+begin
634+ inherited SetItem(AIndex, AValue);
635+end;
636+
637+{ TKRKTaskDialogButtonItem }
638+
639+constructor TKRKTaskDialogButtonItem.Create(ACollection: TCollection);
640+begin
641+ inherited;
642+
643+ Caption := Format(STaskDlgButtonCaption, [ID + 1]);
644+ FElevationRequired := False;
645+end;
646+
647+procedure TKRKTaskDialogButtonItem.DoSetElevationRequired;
648+begin
649+ if Client.Handle <> 0 then
650+ SendMessage(Client.Handle, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, ModalResult, LPARAM(FElevationRequired))
651+end;
652+
653+function TKRKTaskDialogButtonItem.GetButtonText: string;
654+begin
655+ if (FCommandLinkHint <> '') and ((tfUseCommandLinks in Client.Flags) or (tfUseCommandLinksNoIcon in Client.Flags)) then
656+ Result := Caption + #10 + FCommandLinkHint
657+ else
658+ Result := inherited GetButtonText;
659+end;
660+
661+procedure TKRKTaskDialogButtonItem.SetElevationRequired(const AValue: Boolean);
662+begin
663+ if AValue <> FElevationRequired then
664+ begin
665+ FElevationRequired := AValue;
666+ DoSetElevationRequired;
667+ end;
668+end;
669+
670+procedure TKRKTaskDialogButtonItem.SetInitialState;
671+begin
672+ inherited;
673+
674+ if FElevationRequired then
675+ DoSetElevationRequired
676+end;
677+
678+{ TKRKTaskDialogRadioButtonItem }
679+
680+constructor TKRKTaskDialogRadioButtonItem.Create(ACollection: TCollection);
681+begin
682+ inherited;
683+
684+ Caption := Format(STaskDlgRadioButtonCaption, [ID + 1]);
685+end;
686+
687+procedure TKRKTaskDialogRadioButtonItem.DoButtonClick;
688+begin
689+ if Client.Handle <> 0 then
690+ SendMessage(Client.Handle, TDM_CLICK_RADIO_BUTTON, ModalResult, 0);
691+end;
692+
693+procedure TKRKTaskDialogRadioButtonItem.DoSetEnabled;
694+begin
695+ if Client.Handle <> 0 then
696+ SendMessage(Client.Handle, TDM_ENABLE_RADIO_BUTTON, ModalResult, LPARAM(Enabled))
697+end;
698+
699+{ TKRKTaskDialogButtonsEnumerator }
700+
701+constructor TKRKTaskDialogButtonsEnumerator.Create(ACollection: TKRKTaskDialogButtons);
702+begin
703+ inherited Create;
704+ FIndex := -1;
705+ FCollection := ACollection;
706+end;
707+
708+function TKRKTaskDialogButtonsEnumerator.GetCurrent: TKRKTaskDialogBaseButtonItem;
709+begin
710+ Result := FCollection[FIndex];
711+end;
712+
713+function TKRKTaskDialogButtonsEnumerator.MoveNext: Boolean;
714+begin
715+ Result := FIndex < FCollection.Count - 1;
716+
717+ if Result then
718+ Inc(FIndex);
719+end;
720+
423721 end.
Show on old repository browser