瀏覽代碼

IDE.MainForm: Stop the Delphi IDE (11.3) from adding Explicit* properties to the .dfm file.

Jordan Russell 10 月之前
父節點
當前提交
f3eea5ebc9
共有 2 個文件被更改,包括 25 次插入0 次删除
  1. 1 0
      Projects/Src/IDE.MainForm.dfm
  2. 24 0
      Projects/Src/IDE.MainForm.pas

+ 1 - 0
Projects/Src/IDE.MainForm.dfm

@@ -1,6 +1,7 @@
 object MainForm: TMainForm
   Left = 206
   Top = 97
+  BorderStyle = bsNone
   Caption = '*'
   ClientHeight = 306
   ClientWidth = 361

+ 24 - 0
Projects/Src/IDE.MainForm.pas

@@ -528,6 +528,7 @@ type
     function FindSetupDirectiveValue(const DirectiveName: String;
       DefaultValue: Boolean): Boolean; overload;
     function FromCurrentPPI(const XY: Integer): Integer;
+    function GetBorderStyle: TFormBorderStyle;
     procedure Go(AStepMode: TStepMode);
     procedure HideError;
     procedure InitializeFindText(Dlg: TFindDialog);
@@ -583,6 +584,7 @@ type
     procedure ResetAllMemosLineState;
     procedure StartProcess;
     function SaveFile(const AMemo: TIDEScintFileEdit; const SaveAs: Boolean): Boolean;
+    procedure SetBorderStyle(Value: TFormBorderStyle);
     procedure SetErrorLine(const AMemo: TIDEScintFileEdit; const ALine: Integer);
     procedure SetStatusPanelVisible(const AVisible: Boolean);
     procedure SetStepLine(const AMemo: TIDEScintFileEdit; ALine: Integer);
@@ -656,6 +658,8 @@ type
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     function IsShortCut(var Message: TWMKey): Boolean; override;
+  published
+    property BorderStyle: TFormBorderStyle read GetBorderStyle write SetBorderStyle;
   end;
 
 var
@@ -1145,6 +1149,26 @@ begin
   inherited;
 end;
 
+function TMainForm.GetBorderStyle: TFormBorderStyle;
+begin
+  Result := inherited BorderStyle;
+end;
+
+procedure TMainForm.SetBorderStyle(Value: TFormBorderStyle);
+begin
+  { Hack: To stop the Delphi IDE from adding Explicit* properties to the .dfm
+    file every time the unit is saved, we set BorderStyle=bsNone on the form.
+    At run-time, ignore that setting so that BorderStyle stays at the default
+    value, bsSizeable.
+    It would be simpler to change BorderStyle from bsNone to bsSizeable in the
+    form's constructor, but it doesn't quite work: when a form's handle is
+    created while BorderStyle=bsNone, Position=poDefault behaves like
+    poDefaultPosOnly (see TCustomForm.CreateParams). }
+
+  if Value <> bsNone then
+    inherited BorderStyle := Value;
+end;
+
 class procedure TMainForm.AppOnException(Sender: TObject; E: Exception);
 begin
   AppMessageBox(PChar(AddPeriod(E.Message)), SCompilerFormCaption,