CompStartup.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. unit CompStartup;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2004 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Compiler Startup form
  8. $jrsoftware: issrc/Projects/CompStartup.pas,v 1.11 2004/07/22 19:49:39 jr Exp $
  9. }
  10. interface
  11. uses
  12. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13. UIStateForm, StdCtrls, ExtCtrls;
  14. type
  15. TStartupFormResult = (srNone, srEmpty, srWizard, srOpenFile, srOpenDialog,
  16. srOpenDialogExamples);
  17. TStartupForm = class(TUIStateForm)
  18. OKButton: TButton;
  19. CancelButton: TButton;
  20. GroupBox1: TGroupBox;
  21. GroupBox2: TGroupBox;
  22. EmptyRadioButton: TRadioButton;
  23. WizardRadioButton: TRadioButton;
  24. OpenRadioButton: TRadioButton;
  25. OpenListBox: TListBox;
  26. StartupCheck: TCheckBox;
  27. NewImage: TImage;
  28. OpenImage: TImage;
  29. procedure RadioButtonClick(Sender: TObject);
  30. procedure FormCreate(Sender: TObject);
  31. procedure DblClick_(Sender: TObject);
  32. procedure OpenListBoxClick(Sender: TObject);
  33. procedure OKButtonClick(Sender: TObject);
  34. procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
  35. NewDPI: Integer);
  36. private
  37. FResult: TStartupFormResult;
  38. FResultFileName: TFileName;
  39. procedure SetMRUList(const MRUList: TStringList);
  40. procedure UpdateImages;
  41. public
  42. property MRUList: TStringList write SetMRUList;
  43. property Result: TStartupFormResult read FResult;
  44. property ResultFileName: TFileName read FResultFileName;
  45. end;
  46. implementation
  47. uses
  48. CompMsgs, CmnFunc, CmnFunc2, CompForm, ComCtrls;
  49. {$R *.DFM}
  50. procedure TStartupForm.SetMRUList(const MRUList: TStringList);
  51. var
  52. I: Integer;
  53. begin
  54. for I := 0 to MRUList.Count-1 do
  55. OpenListBox.Items.Add(MRUList[I]);
  56. UpdateHorizontalExtent(OpenListBox);
  57. end;
  58. procedure TStartupForm.UpdateImages;
  59. function GetBitmap(const Button: TToolButton; const WH: Integer): TBitmap;
  60. begin
  61. Result := CompileForm.ToolbarImageCollection.GetBitmap(Button.ImageIndex, WH, WH)
  62. end;
  63. var
  64. WH: Integer;
  65. begin
  66. { After a DPI change the button's Width and Height isn't yet updated, so calculate it ourselves }
  67. WH := MulDiv(16, CurrentPPI, 96);
  68. NewImage.Picture.Bitmap := GetBitmap(CompileForm.NewButton, WH);
  69. OpenImage.Picture.Bitmap := GetBitmap(CompileForm.OpenButton, WH);
  70. end;
  71. procedure TStartupForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI,
  72. NewDPI: Integer);
  73. begin
  74. UpdateImages;
  75. end;
  76. procedure TStartupForm.FormCreate(Sender: TObject);
  77. begin
  78. FResult := srNone;
  79. InitFormFont(Self);
  80. UpdateImages;
  81. OpenListBox.Items.Add(SCompilerExampleScripts);
  82. OpenListBox.Items.Add(SCompilerMoreFiles);
  83. OpenListBox.ItemIndex := 0;
  84. UpdateHorizontalExtent(OpenListBox);
  85. ActiveControl := OpenRadioButton;
  86. end;
  87. procedure TStartupForm.RadioButtonClick(Sender: TObject);
  88. begin
  89. EmptyRadioButton.Checked := Sender = EmptyRadioButton;
  90. WizardRadioButton.Checked := Sender = WizardRadioButton;
  91. OpenRadioButton.Checked := Sender = OpenRadioButton;
  92. if Sender = OpenRadioButton then begin
  93. if OpenListBox.ItemIndex = -1 then
  94. OpenListBox.ItemIndex := 0;
  95. end
  96. else
  97. OpenListBox.ItemIndex := -1;
  98. end;
  99. procedure TStartupForm.DblClick_(Sender: TObject);
  100. begin
  101. if OkButton.Enabled then
  102. OkButton.Click;
  103. end;
  104. procedure TStartupForm.OpenListBoxClick(Sender: TObject);
  105. begin
  106. OpenRadioButton.Checked := True;
  107. end;
  108. procedure TStartupForm.OKButtonClick(Sender: TObject);
  109. begin
  110. if EmptyRadioButton.Checked then
  111. FResult := srEmpty
  112. else if WizardRadioButton.Checked then
  113. FResult := srWizard
  114. else { if OpenRadioButton.Checked then } begin
  115. if OpenListBox.ItemIndex = 0 then
  116. FResult := srOpenDialogExamples
  117. else if OpenListBox.ItemIndex > 1 then begin
  118. FResult := srOpenFile;
  119. FResultFileName := OpenListBox.Items[OpenListBox.ItemIndex];
  120. end else
  121. FResult := srOpenDialog;
  122. end;
  123. end;
  124. end.