forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptDlg.pas
833 lines (738 loc) · 24.7 KB
/
ScriptDlg.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
unit ScriptDlg;
{
Inno Setup
Copyright (C) 1997-2012 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Custom wizard pages
}
interface
{$I VERSION.INC}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls,
Wizard,
NewCheckListBox, NewStaticText, NewProgressBar, PasswordEdit, RichEditViewer,
BidiCtrls, TaskbarProgressFunc;
type
TInputQueryWizardPage = class(TWizardPage)
private
FEdits: TList;
FPromptLabels: TList;
FSubCaptionLabel: TNewStaticText;
FY: Integer;
function GetEdit(Index: Integer): TPasswordEdit;
function GetPromptLabel(Index: Integer): TNewStaticText;
function GetValue(Index: Integer): String;
procedure SetValue(Index: Integer; const Value: String);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Add(const APrompt: String; const APassword: Boolean): Integer;
property Edits[Index: Integer]: TPasswordEdit read GetEdit;
procedure Initialize(const SubCaption: String);
property PromptLabels[Index: Integer]: TNewStaticText read GetPromptLabel;
property SubCaptionLabel: TNewStaticText read FSubCaptionLabel;
property Values[Index: Integer]: String read GetValue write SetValue;
end;
TInputOptionWizardPage = class(TWizardPage)
private
FCheckListBox: TNewCheckListBox;
FExclusive: Boolean;
FSubCaptionLabel: TNewStaticText;
function GetSelectedValueIndex: Integer;
function GetValue(Index: Integer): Boolean;
procedure SetSelectedValueIndex(Value: Integer);
procedure SetValue(Index: Integer; Value: Boolean);
public
function Add(const ACaption: String): Integer;
function AddEx(const ACaption: String; const ALevel: Byte; const AExclusive: Boolean): Integer;
property CheckListBox: TNewCheckListBox read FCheckListBox;
procedure Initialize(const SubCaption: String; const Exclusive, ListBox: Boolean);
property SelectedValueIndex: Integer read GetSelectedValueIndex write SetSelectedValueIndex;
property SubCaptionLabel: TNewStaticText read FSubCaptionLabel;
property Values[Index: Integer]: Boolean read GetValue write SetValue;
end;
TInputDirWizardPage = class(TWizardPage)
private
FAppendDir: Boolean;
FButtons: TList;
FEdits: TList;
FNewFolderName: String;
FPromptLabels: TList;
FSubCaptionLabel: TNewStaticText;
FY: Integer;
procedure ButtonClick(Sender: TObject);
function GetButton(Index: Integer): TNewButton;
function GetEdit(Index: Integer): TEdit;
function GetPromptLabel(Index: Integer): TNewStaticText;
function GetValue(Index: Integer): String;
procedure SetValue(Index: Integer; const Value: String);
protected
procedure NextButtonClick(var Continue: Boolean); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Add(const APrompt: String): Integer;
property Buttons[Index: Integer]: TNewButton read GetButton;
property Edits[Index: Integer]: TEdit read GetEdit;
procedure Initialize(const SubCaption: String; const AppendDir: Boolean;
const NewFolderName: String);
property PromptLabels[Index: Integer]: TNewStaticText read GetPromptLabel;
property SubCaptionLabel: TNewStaticText read FSubCaptionLabel;
property Values[Index: Integer]: String read GetValue write SetValue;
end;
TInputFileWizardPage = class(TWizardPage)
private
FButtons: TList;
FEdits: TList;
FInputFileDefaultExtensions: TStringList;
FInputFileFilters: TStringList;
FPromptLabels: TList;
FSubCaptionLabel: TNewStaticText;
FY: Integer;
procedure ButtonClick(Sender: TObject);
function GetButton(Index: Integer): TNewButton;
function GetEdit(Index: Integer): TEdit;
function GetPromptLabel(Index: Integer): TNewStaticText;
function GetValue(Index: Integer): String;
procedure SetValue(Index: Integer; const Value: String);
function GetIsSaveButton(Index: Integer): Boolean;
procedure SetIsSaveButton(Index: Integer; const IsSaveButton: Boolean);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Add(const APrompt, AFilter, ADefaultExtension: String): Integer;
property Buttons[Index: Integer]: TNewButton read GetButton;
property Edits[Index: Integer]: TEdit read GetEdit;
procedure Initialize(const SubCaption: String);
property PromptLabels[Index: Integer]: TNewStaticText read GetPromptLabel;
property SubCaptionLabel: TNewStaticText read FSubCaptionLabel;
property Values[Index: Integer]: String read GetValue write SetValue;
property IsSaveButton[Index: Integer]: Boolean read GetIsSaveButton write SetIsSaveButton;
end;
TOutputMsgWizardPage = class(TWizardPage)
private
FMsgLabel: TNewStaticText;
public
procedure Initialize(const Msg: String);
property MsgLabel: TNewStaticText read FMsgLabel;
end;
TOutputMsgMemoWizardPage = class(TWizardPage)
private
FRichEditViewer: TRichEditViewer;
FSubCaptionLabel: TNewStaticText;
public
procedure Initialize(const SubCaption: String; const Msg: AnsiString);
property RichEditViewer: TRichEditViewer read FRichEditViewer;
property SubCaptionLabel: TNewStaticText read FSubCaptionLabel;
end;
TOutputProgressWizardPage = class(TWizardPage)
private
FMsg1Label: TNewStaticText;
FMsg2Label: TNewStaticText;
FProgressBar: TNewProgressBar;
FSavePageID: Integer;
procedure ProcessMsgs;
public
constructor Create(AOwner: TComponent); override;
procedure Hide;
procedure Initialize;
property Msg1Label: TNewStaticText read FMsg1Label;
property Msg2Label: TNewStaticText read FMsg2Label;
property ProgressBar: TNewProgressBar read FProgressBar;
procedure SetProgress(const Position, Max: Longint);
procedure SetText(const Msg1, Msg2: String);
procedure Show;
end;
implementation
uses
Struct, Main, SelFolderForm, Msgs, MsgIDs, PathFunc, CmnFunc, CmnFunc2,
BrowseFunc;
const
DefaultLabelHeight = 14;
DefaultBoxTop = 24; { relative to top of InnerNotebook }
DefaultBoxBottom = DefaultBoxTop + 205;
{------}
procedure SetCtlParent(const AControl, AParent: TWinControl);
{ Like assigning to AControl.Parent, but puts the control at the *bottom* of
the z-order instead of the top, for MSAA compatibility. }
var
OldVisible: Boolean;
begin
{ Hide the control so the handle won't be created yet, so that unnecessary
"OBJ_REORDER" MSAA events don't get sent }
OldVisible := AControl.Visible;
AControl.Visible := False;
AControl.Parent := AParent;
AControl.SendToBack;
AControl.Visible := OldVisible;
end;
{--- InputQuery ---}
constructor TInputQueryWizardPage.Create(AOwner: TComponent);
begin
inherited;
FEdits := TList.Create;
FPromptLabels := TList.Create;
end;
destructor TInputQueryWizardPage.Destroy;
begin
FPromptLabels.Free;
FEdits.Free;
inherited;
end;
procedure TInputQueryWizardPage.Initialize(const SubCaption: String);
begin
FSubCaptionLabel := TNewStaticText.Create(Self);
with FSubCaptionLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := SubCaption;
Parent := Surface;
end;
FY := WizardForm.AdjustLabelHeight(FSubCaptionLabel) + WizardForm.ScalePixelsY(DefaultBoxTop);
end;
function TInputQueryWizardPage.Add(const APrompt: String;
const APassword: Boolean): Integer;
var
PromptLabel: TNewStaticText;
Edit: TPasswordEdit;
begin
if APrompt <> '' then begin
PromptLabel := TNewStaticText.Create(Self);
with PromptLabel do begin
AutoSize := False;
Top := FY;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := APrompt;
end;
SetCtlParent(PromptLabel, Surface);
Inc(FY, WizardForm.AdjustLabelHeight(PromptLabel) + WizardForm.ScalePixelsY(16));
end else
PromptLabel := nil;
Edit := TPasswordEdit.Create(Self);
with Edit do begin
Password := APassword;
Top := FY;
Width := SurfaceWidth;
end;
SetCtlParent(Edit, Surface);
Inc(FY, WizardForm.ScalePixelsY(36));
if PromptLabel <> nil then
PromptLabel.FocusControl := Edit;
FPromptLabels.Add(PromptLabel);
Result := FEdits.Add(Edit);
end;
function TInputQueryWizardPage.GetEdit(Index: Integer): TPasswordEdit;
begin
Result := TPasswordEdit(FEdits[Index]);
end;
function TInputQueryWizardPage.GetPromptLabel(Index: Integer): TNewStaticText;
begin
Result := TNewStaticText(FPromptLabels[Index]);
end;
function TInputQueryWizardPage.GetValue(Index: Integer): String;
begin
Result := GetEdit(Index).Text;
end;
procedure TInputQueryWizardPage.SetValue(Index: Integer; const Value: String);
begin
GetEdit(Index).Text := Value;
end;
{--- InputOption ---}
procedure TInputOptionWizardPage.Initialize(const SubCaption: String;
const Exclusive, ListBox: Boolean);
var
CaptionYDiff: Integer;
begin
FSubCaptionLabel := TNewStaticText.Create(Self);
with SubCaptionLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := SubCaption;
Parent := Surface;
end;
CaptionYDiff := WizardForm.AdjustLabelHeight(SubCaptionLabel);
FCheckListBox := TNewCheckListBox.Create(Self);
with FCheckListBox do begin
Top := CaptionYDiff + WizardForm.ScalePixelsY(DefaultBoxTop);
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultBoxBottom) - Top;
Flat := ListBox and (shFlatComponentsList in SetupHeader.Options);
end;
SetCtlParent(FCheckListBox, Surface);
FExclusive := Exclusive;
if not ListBox then begin
FCheckListBox.BorderStyle := bsNone;
FCheckListBox.Color := clBtnFace;
FCheckListBox.MinItemHeight := WizardForm.ScalePixelsY(22);
FCheckListBox.WantTabs := True;
end;
end;
function TInputOptionWizardPage.Add(const ACaption: String): Integer;
begin
Result := AddEx(ACaption, 0, FExclusive);
end;
function TInputOptionWizardPage.AddEx(const ACaption: String;
const ALevel: Byte; const AExclusive: Boolean): Integer;
begin
if AExclusive then
Result := FCheckListBox.AddRadioButton(ACaption, '', ALevel, False, True, nil)
else
Result := FCheckListBox.AddCheckBox(ACaption, '', ALevel, False, True, True,
True, nil);
end;
function TInputOptionWizardPage.GetSelectedValueIndex: Integer;
var
I: Integer;
begin
for I := 0 to FCheckListBox.Items.Count-1 do
if (FCheckListBox.ItemLevel[I] = 0) and FCheckListBox.Checked[I] then begin
Result := I;
Exit;
end;
Result := -1;
end;
function TInputOptionWizardPage.GetValue(Index: Integer): Boolean;
begin
Result := FCheckListBox.Checked[Index];
end;
procedure TInputOptionWizardPage.SetSelectedValueIndex(Value: Integer);
var
I: Integer;
begin
for I := 0 to FCheckListBox.Items.Count-1 do
if FCheckListBox.ItemLevel[I] = 0 then
FCheckListBox.Checked[I] := (I = Value);
end;
procedure TInputOptionWizardPage.SetValue(Index: Integer; Value: Boolean);
begin
FCheckListBox.Checked[Index] := Value;
end;
{--- InputDir ---}
constructor TInputDirWizardPage.Create(AOwner: TComponent);
begin
inherited;
FButtons := TList.Create;
FEdits := TList.Create;
FPromptLabels := TList.Create;
end;
destructor TInputDirWizardPage.Destroy;
begin
FPromptLabels.Free;
FEdits.Free;
FButtons.Free;
inherited;
end;
procedure TInputDirWizardPage.ButtonClick(Sender: TObject);
var
I: Integer;
Edit: TEdit;
S: String;
begin
I := FButtons.IndexOf(Sender);
if I <> -1 then begin
Edit := TEdit(FEdits[I]);
S := Edit.Text;
if ShowSelectFolderDialog(False, FAppendDir, S, FNewFolderName) then
Edit.Text := S;
end;
end;
procedure TInputDirWizardPage.NextButtonClick(var Continue: Boolean);
var
I: Integer;
Edit: TEdit;
begin
for I := 0 to FEdits.Count-1 do begin
Edit := FEdits[I];
if not ValidateCustomDirEdit(Edit, True, True, True) then begin
if WizardForm.Visible then
Edit.SetFocus;
Continue := False;
Exit;
end;
end;
inherited;
end;
procedure TInputDirWizardPage.Initialize(const SubCaption: String;
const AppendDir: Boolean; const NewFolderName: String);
begin
FSubCaptionLabel := TNewStaticText.Create(Self);
with FSubCaptionLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := SubCaption;
Parent := Surface;
end;
FY := WizardForm.AdjustLabelHeight(FSubCaptionLabel) + WizardForm.ScalePixelsY(DefaultBoxTop);
FAppendDir := AppendDir;
FNewFolderName := NewFolderName;
end;
function TInputDirWizardPage.Add(const APrompt: String): Integer;
var
ButtonWidth: Integer;
PromptLabel: TNewStaticText;
Edit: TEdit;
Button: TNewButton;
begin
ButtonWidth := WizardForm.CalculateButtonWidth([msgButtonWizardBrowse]);
if APrompt <> '' then begin
PromptLabel := TNewStaticText.Create(Self);
with PromptLabel do begin
AutoSize := False;
Top := FY;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := APrompt;
end;
SetCtlParent(PromptLabel, Surface);
Inc(FY, WizardForm.AdjustLabelHeight(PromptLabel) + WizardForm.ScalePixelsY(16));
end else
PromptLabel := nil;
Edit := TEdit.Create(Self);
with Edit do begin
Top := FY;
Width := SurfaceWidth-ButtonWidth-WizardForm.ScalePixelsX(10);
end;
SetCtlParent(Edit, Surface);
TryEnableAutoCompleteFileSystem(Edit.Handle);
if PromptLabel <> nil then
PromptLabel.FocusControl := Edit;
Button := TNewButton.Create(Self);
with Button do begin
Left := SurfaceWidth-ButtonWidth;
Top := Edit.Top-1;
Width := ButtonWidth;
Height := WizardForm.NextButton.Height;
if FEdits.Count = 0 then
Caption := SetupMessages[msgButtonWizardBrowse]
else
{ Can't use the same accel key for secondary buttons... }
Caption := RemoveAccelChar(SetupMessages[msgButtonWizardBrowse]);
OnClick := ButtonClick;
end;
SetCtlParent(Button, Surface);
Inc(FY, WizardForm.ScalePixelsY(36));
FButtons.Add(Button);
FPromptLabels.Add(PromptLabel);
Result := FEdits.Add(Edit);
end;
function TInputDirWizardPage.GetButton(Index: Integer): TNewButton;
begin
Result := TNewButton(FButtons[Index]);
end;
function TInputDirWizardPage.GetEdit(Index: Integer): TEdit;
begin
Result := TEdit(FEdits[Index]);
end;
function TInputDirWizardPage.GetPromptLabel(Index: Integer): TNewStaticText;
begin
Result := TNewStaticText(FPromptLabels[Index]);
end;
function TInputDirWizardPage.GetValue(Index: Integer): String;
begin
Result := GetEdit(Index).Text;
end;
procedure TInputDirWizardPage.SetValue(Index: Integer; const Value: String);
begin
GetEdit(Index).Text := RemoveBackslashUnlessRoot(PathExpand(Value));
end;
{--- InputFile ---}
constructor TInputFileWizardPage.Create(AOwner: TComponent);
begin
inherited;
FButtons := TList.Create;
FEdits := TList.Create;
FInputFileDefaultExtensions := TStringList.Create;
FInputFileFilters := TStringList.Create;
FPromptLabels := TList.Create;
end;
destructor TInputFileWizardPage.Destroy;
begin
FPromptLabels.Free;
FInputFileFilters.Free;
FInputFileDefaultExtensions.Free;
FEdits.Free;
FButtons.Free;
inherited;
end;
procedure TInputFileWizardPage.ButtonClick(Sender: TObject);
var
I: Integer;
Edit: TEdit;
FileName: String;
begin
I := FButtons.IndexOf(Sender);
if I <> -1 then begin
Edit := TEdit(FEdits[I]);
FileName := Edit.Text;
if (not IsSaveButton[I] and NewGetOpenFileName(RemoveAccelChar(SetupMessages[msgButtonWizardBrowse]),
FileName, PathExtractPath(FileName), FInputFileFilters[I],
FInputFileDefaultExtensions[I], Surface.Handle)) or
(IsSaveButton[I] and NewGetSaveFileName(RemoveAccelChar(SetupMessages[msgButtonWizardBrowse]),
FileName, PathExtractPath(FileName), FInputFileFilters[I],
FInputFileDefaultExtensions[I], Surface.Handle)) then
Edit.Text := FileName;
end;
end;
procedure TInputFileWizardPage.Initialize(const SubCaption: String);
begin
FSubCaptionLabel := TNewStaticText.Create(Self);
with FSubCaptionLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := SubCaption;
Parent := Surface;
end;
FY := WizardForm.AdjustLabelHeight(FSubCaptionLabel) + WizardForm.ScalePixelsY(DefaultBoxTop);
end;
function TInputFileWizardPage.Add(const APrompt, AFilter,
ADefaultExtension: String): Integer;
var
ButtonWidth: Integer;
PromptLabel: TNewStaticText;
Edit: TEdit;
Button: TNewButton;
begin
ButtonWidth := WizardForm.CalculateButtonWidth([msgButtonWizardBrowse]);
if APrompt <> '' then begin
PromptLabel := TNewStaticText.Create(Self);
with PromptLabel do begin
AutoSize := False;
Top := FY;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := APrompt;
end;
SetCtlParent(PromptLabel, Surface);
Inc(FY, WizardForm.AdjustLabelHeight(PromptLabel) + WizardForm.ScalePixelsY(16));
end else
PromptLabel := nil;
Edit := TEdit.Create(Self);
with Edit do begin
Top := FY;
Width := SurfaceWidth-ButtonWidth-WizardForm.ScalePixelsX(10);
end;
SetCtlParent(Edit, Surface);
TryEnableAutoCompleteFileSystem(Edit.Handle);
if PromptLabel <> nil then
PromptLabel.FocusControl := Edit;
Button := TNewButton.Create(Self);
with Button do begin
Left := SurfaceWidth-ButtonWidth;
Top := Edit.Top-1;
Width := ButtonWidth;
Height := WizardForm.NextButton.Height;
if FButtons.Count = 0 then
Caption := SetupMessages[msgButtonWizardBrowse]
else
{ Can't use the same accel key for secondary buttons... }
Caption := RemoveAccelChar(SetupMessages[msgButtonWizardBrowse]);
OnClick := ButtonClick;
end;
SetCtlParent(Button, Surface);
Inc(FY, WizardForm.ScalePixelsY(36));
FInputFileFilters.Add(AFilter);
FInputFileDefaultExtensions.Add(ADefaultExtension);
FButtons.Add(Button);
FPromptLabels.Add(PromptLabel);
Result := FEdits.Add(Edit);
end;
function TInputFileWizardPage.GetButton(Index: Integer): TNewButton;
begin
Result := TNewButton(FButtons[Index]);
end;
function TInputFileWizardPage.GetEdit(Index: Integer): TEdit;
begin
Result := TEdit(FEdits[Index]);
end;
function TInputFileWizardPage.GetPromptLabel(Index: Integer): TNewStaticText;
begin
Result := TNewStaticText(FPromptLabels[Index]);
end;
function TInputFileWizardPage.GetValue(Index: Integer): String;
begin
Result := GetEdit(Index).Text;
end;
procedure TInputFileWizardPage.SetValue(Index: Integer; const Value: String);
begin
GetEdit(Index).Text := Value;
end;
function TInputFileWizardPage.GetIsSaveButton(Index: Integer): Boolean;
begin
Result := GetButton(Index).Tag = 1;
end;
procedure TInputFileWizardPage.SetIsSaveButton(Index: Integer; const IsSaveButton: Boolean);
begin
if IsSaveButton then
GetButton(Index).Tag := 1
else
GetButton(Index).Tag := 0;
end;
{--- OutputMsg ---}
procedure TOutputMsgWizardPage.Initialize(const Msg: String);
begin
FMsgLabel := TNewStaticText.Create(Self);
with FMsgLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := Msg;
Parent := Surface;
end;
WizardForm.AdjustLabelHeight(MsgLabel);
end;
{--- OutputMsgMemo ---}
procedure TOutputMsgMemoWizardPage.Initialize(const SubCaption: String; const Msg: AnsiString);
var
Y: Integer;
begin
Y := 0;
if SubCaption <> '' then begin
FSubCaptionLabel := TNewStaticText.Create(Self);
with FSubCaptionLabel do begin
AutoSize := False;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultLabelHeight);
WordWrap := True;
Caption := SubCaption;
Parent := Surface;
end;
Inc(Y, WizardForm.ScalePixelsY(DefaultBoxTop) +
WizardForm.AdjustLabelHeight(FSubCaptionLabel));
end else
FSubCaptionLabel := nil;
FRichEditViewer := TRichEditViewer.Create(Self);
with FRichEditViewer do begin
Top := Y;
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(DefaultBoxBottom) - Y;
ReadOnly := True;
ScrollBars := ssVertical;
WantReturns := False;
end;
SetCtlParent(FRichEditViewer, Surface);
with FRichEditViewer do begin
UseRichEdit := True;
RTFText := Msg;
end;
end;
{--- OutputProgress ---}
constructor TOutputProgressWizardPage.Create(AOwner: TComponent);
begin
inherited;
Style := Style + [psAlwaysSkip, psNoButtons];
end;
procedure TOutputProgressWizardPage.Initialize;
begin
FMsg1Label := TNewStaticText.Create(Self);
with FMsg1Label do begin
AutoSize := False;
ShowAccelChar := False;
Width := SurfaceWidth;
Height := WizardForm.StatusLabel.Height;
WordWrap := WizardForm.StatusLabel.WordWrap;
Parent := Surface;
end;
FMsg2Label := TNewStaticText.Create(Self);
with FMsg2Label do begin
AutoSize := False;
ForceLTRReading := True;
ShowAccelChar := False;
Top := WizardForm.ScalePixelsY(16);
Width := SurfaceWidth;
Height := WizardForm.FileNameLabel.Height;
end;
SetCtlParent(FMsg2Label, Surface);
FProgressBar := TNewProgressBar.Create(Self);
with FProgressBar do begin
Top := WizardForm.ScalePixelsY(42);
Width := SurfaceWidth;
Height := WizardForm.ScalePixelsY(21);
Visible := False;
end;
SetCtlParent(FProgressBar, Surface);
end;
procedure TOutputProgressWizardPage.Hide;
begin
if (WizardForm.CurPageID = ID) and (FSavePageID <> 0) then begin
SetMessageBoxCallbackFunc(nil, 0);
SetAppTaskbarProgressState(tpsNoProgress);
WizardForm.SetCurPage(FSavePageID);
FSavePageID := 0;
end;
end;
procedure TOutputProgressWizardPage.ProcessMsgs;
{ Process messages to repaint and keep Windows from thinking the process is
hung. This is safe; due to the psNoButtons style the user shouldn't be able
to cancel or do anything else during this time. }
begin
if WizardForm.CurPageID = ID then
Application.ProcessMessages;
end;
procedure TOutputProgressWizardPage.SetProgress(const Position, Max: Longint);
begin
if Max > 0 then begin
FProgressBar.Max := Max;
FProgressBar.Position := Position;
FProgressBar.Visible := True;
SetAppTaskbarProgressState(tpsNormal);
SetAppTaskbarProgressValue(Position, Max);
end
else begin
FProgressBar.Visible := False;
SetAppTaskbarProgressState(tpsNoProgress);
end;
ProcessMsgs;
end;
procedure TOutputProgressWizardPage.SetText(const Msg1, Msg2: String);
begin
FMsg1Label.Caption := Msg1;
FMsg2Label.Caption := MinimizePathName(Msg2, FMsg2Label.Font,
FMsg2Label.Width);
ProcessMsgs;
end;
procedure OutputProgressWizardPageMessageBoxCallback(const Flags: LongInt; const After: Boolean;
const Param: LongInt);
const
States: array [TNewProgressBarState] of TTaskbarProgressState =
(tpsNormal, tpsError, tpsPaused);
var
OutputProgressWizardPage: TOutputProgressWizardPage;
NewState: TNewProgressBarState;
begin
OutputProgressWizardPage := TOutputProgressWizardPage(Param);
if After then
NewState := npbsNormal
else if (Flags and MB_ICONSTOP) <> 0 then
NewState := npbsError
else
NewState := npbsPaused;
with OutputProgressWizardPage.ProgressBar do begin
State := NewState;
Invalidate;
end;
SetAppTaskbarProgressState(States[NewState]);
end;
procedure TOutputProgressWizardPage.Show;
begin
if WizardForm.CurPageID <> ID then begin
FSavePageID := WizardForm.CurPageID;
WizardForm.SetCurPage(ID);
SetMessageBoxCallbackFunc(OutputProgressWizardPageMessageBoxCallback, LongInt(Self));
ProcessMsgs;
end;
end;
end.