| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- unit CompStartup;
- {
- Inno Setup
- Copyright (C) 1997-2004 Jordan Russell
- Portions by Martijn Laan
- For conditions of distribution and use, see LICENSE.TXT.
- Compiler Startup form
- $jrsoftware: issrc/Projects/CompStartup.pas,v 1.11 2004/07/22 19:49:39 jr Exp $
- }
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- UIStateForm, StdCtrls, ExtCtrls;
- type
- TStartupFormResult = (srNone, srEmpty, srWizard, srOpenFile, srOpenDialog,
- srOpenDialogExamples);
- TStartupForm = class(TUIStateForm)
- OKButton: TButton;
- CancelButton: TButton;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- EmptyRadioButton: TRadioButton;
- WizardRadioButton: TRadioButton;
- OpenRadioButton: TRadioButton;
- OpenListBox: TListBox;
- StartupCheck: TCheckBox;
- NewImage: TImage;
- OpenImage: TImage;
- procedure RadioButtonClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure DblClick_(Sender: TObject);
- procedure OpenListBoxClick(Sender: TObject);
- procedure OKButtonClick(Sender: TObject);
- procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
- NewDPI: Integer);
- private
- FResult: TStartupFormResult;
- FResultFileName: TFileName;
- procedure SetMRUList(const MRUList: TStringList);
- procedure UpdateImages;
- public
- property MRUList: TStringList write SetMRUList;
- property Result: TStartupFormResult read FResult;
- property ResultFileName: TFileName read FResultFileName;
- end;
- implementation
- uses
- CompMsgs, CmnFunc, CmnFunc2, CompForm, ComCtrls;
- {$R *.DFM}
- procedure TStartupForm.SetMRUList(const MRUList: TStringList);
- var
- I: Integer;
- begin
- for I := 0 to MRUList.Count-1 do
- OpenListBox.Items.Add(MRUList[I]);
- UpdateHorizontalExtent(OpenListBox);
- end;
- procedure TStartupForm.UpdateImages;
- function GetBitmap(const Button: TToolButton; const WH: Integer): TBitmap;
- begin
- Result := CompileForm.ToolbarImageCollection.GetBitmap(Button.ImageIndex, WH, WH)
- end;
- var
- WH: Integer;
- begin
- { After a DPI change the button's Width and Height isn't yet updated, so calculate it ourselves }
- WH := MulDiv(16, CurrentPPI, 96);
- NewImage.Picture.Bitmap := GetBitmap(CompileForm.NewButton, WH);
- OpenImage.Picture.Bitmap := GetBitmap(CompileForm.OpenButton, WH);
- end;
- procedure TStartupForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
- NewDPI: Integer);
- begin
- UpdateImages;
- end;
- procedure TStartupForm.FormCreate(Sender: TObject);
- begin
- FResult := srNone;
- InitFormFont(Self);
- UpdateImages;
- OpenListBox.Items.Add(SCompilerExampleScripts);
- OpenListBox.Items.Add(SCompilerMoreFiles);
- OpenListBox.ItemIndex := 0;
- UpdateHorizontalExtent(OpenListBox);
- ActiveControl := OpenRadioButton;
- end;
- procedure TStartupForm.RadioButtonClick(Sender: TObject);
- begin
- EmptyRadioButton.Checked := Sender = EmptyRadioButton;
- WizardRadioButton.Checked := Sender = WizardRadioButton;
- OpenRadioButton.Checked := Sender = OpenRadioButton;
- if Sender = OpenRadioButton then begin
- if OpenListBox.ItemIndex = -1 then
- OpenListBox.ItemIndex := 0;
- end
- else
- OpenListBox.ItemIndex := -1;
- end;
- procedure TStartupForm.DblClick_(Sender: TObject);
- begin
- if OkButton.Enabled then
- OkButton.Click;
- end;
- procedure TStartupForm.OpenListBoxClick(Sender: TObject);
- begin
- OpenRadioButton.Checked := True;
- end;
- procedure TStartupForm.OKButtonClick(Sender: TObject);
- begin
- if EmptyRadioButton.Checked then
- FResult := srEmpty
- else if WizardRadioButton.Checked then
- FResult := srWizard
- else { if OpenRadioButton.Checked then } begin
- if OpenListBox.ItemIndex = 0 then
- FResult := srOpenDialogExamples
- else if OpenListBox.ItemIndex > 1 then begin
- FResult := srOpenFile;
- FResultFileName := OpenListBox.Items[OpenListBox.ItemIndex];
- end else
- FResult := srOpenDialog;
- end;
- end;
- end.
|