dummzeuch 1505 Posted December 16, 2020 I just found this code in vcl.forms in Delphi 10.2.3: function ShouldScale(const self: TCustomForm): Boolean; // this is just to make code more readable begin Result := self.FScaled and not (csDesigning in self.ComponentState) and ((self.Owner = nil) or not (LowerCase(self.Owner.ClassName) = 'teditwindow')) // we are not in an edit window and ((self.Parent = nil) or not (csDesigning in self.Parent.ComponentState) or not (csFreeNotification in self.Parent.ComponentState)); end; What is this comparison with 'teditwindow' about? Looks as if somebody had to add this to make the IDE behave. What if somebody's program uses a form called TEditWindow? 1 1 Share this post Link to post
Uwe Raabe 2057 Posted December 16, 2020 18 minutes ago, dummzeuch said: What if somebody's program uses a form called TEditWindow? ... and makes that TEditWindow instance the owner of a to-be-scaled TCustomForm. What bothers me more ist the csFreeNotification condition at the end. I mean, how is that related to scaling? Share this post Link to post
Pat Foley 51 Posted December 16, 2020 2 hours ago, Kas Ob. said: LowerCase is more annoying More annoying is self.FScaled :( Share this post Link to post
Alexander Elagin 143 Posted December 16, 2020 This function exists also in 10.1, but for obvious reasons there is no trace of this code in Delphi XE. Somebody probably used some black magic to force scaling engine into the two decades old and pretty stable code of the Forms unit, but had to put duct tape here and there to make it work. No doubt that the IDE theming used even more glue and tape, that's why the themed IDE is a slow monster. Share this post Link to post
Pat Foley 51 Posted December 16, 2020 Its in 10.4.1. Would adding csTheming csScaling switches be better? csScalingDPIonly? I just want the menubar font to change. Share this post Link to post
Guest Posted December 16, 2020 (edited) My scenary: RAD Studio 10.3.3 Arch (Rio) VLC project for test in my observations I had: the "teditwindow" just exist only one reference to this name/string in all (*.*) files from RAD Studio 10.3.3 Arch only in "function ShouldScaled(...)", none any other file as in "csDesigning" verification, for me, do sense verify "csFreeNotification" too! as this action can be executed in many situations by many others actions, then, do sense, verify it. as im expert, then, it's just my observation, not afirmation! source from RAD... called by "procedure TCustomForm.ScaleForCurrentDpi;" function ShouldScale(const Self: TCustomForm): Boolean; // this is just to make code more readable var lSelfName : string; lSelfFScaled : Boolean; lSelfcsDesigning : Boolean; lSelfOwner : Boolean; lSelfOwnerName : string; lSelfOwnerClassName : string; lSelfParentName : string; lSelfParentcsDesining: Boolean; lcsFreeNotification : Boolean; begin lSelfName := ''; // ... very more readable yet! lSelfFScaled := False; lSelfcsDesigning := False; lSelfOwnerName := ''; lSelfOwner := False; lSelfOwnerClassName := ''; lSelfParentName := ''; lSelfParentcsDesining := False; lcsFreeNotification := False; // // "ToString" if "Name" empty if not(Self = nil) then begin lSelfName := Self.ToString; { TfrmFormMain } lSelfFScaled := Self.FScaled; { true } lSelfcsDesigning := (csDesigning in Self.ComponentState); { false = [csLoading]} // if not(Self.Owner = nil) then begin lSelfOwnerName := Self.Owner.ToString; { TAppliation } lSelfOwnerClassName := Self.Owner.ClassName; { TAppliation } end; // if not(Self.Parent = nil) then { = nil } begin lSelfParentName := Self.Parent.ToString; lSelfParentcsDesining := (csDesigning in Self.Parent.ComponentState); lcsFreeNotification := (csFreeNotification in Self.Parent.ComponentState); end; end; // // final resulted for a simple: create application with just one "TForm" and click F9 key to run with Debug // // true true true or true true true true //result := (True and not(False)) and (True or not(false)) and ((true or not(false)) or not(false)) //csFreeNotification = One or more other components have requested that this component notify them when it is destroyed. This flag is set when another component calls this component's FreeNotification method. { So, if used extensively by many other actions, then it makes sense to check is "he" (the component / class) has not yet been released! Thus, how "csDesigning" is checked so that the component does not perform certain actions when it is not yet in a "runtime" environment! } // { in all code source of RAD 10.3.3 Arch, just exist "one reference to TEditWindow"... here!!! } // // // if "FormXXX.Scaled := False" is defined in Design-time == the function ShouldScaled will result = False, anyway! // Result := Self.FScaled and not(csDesigning in Self.ComponentState) and ((Self.Owner = nil) or not(LowerCase(Self.Owner.ClassName) = 'teditwindow')) // we are not in an edit window and ((Self.Parent = nil) or not(csDesigning in Self.Parent.ComponentState) or not(csFreeNotification in Self.Parent.ComponentState)); end; my frmFormMain for test implementation {$R *.dfm} procedure TfrmFormMain.FormCreate(Sender: TObject); begin // // if defined in Design-time == the function ShouldScaled will result = False, anyway! // Self.Scaled := false; // occurr ... very very later than "function ShouldScale(const Self: TCustomForm): Boolean;" end; initialization // if defined: (of course, the object not created yet) // frmFormMain.Scaled := false; // "AV", in Vcl.Forms.pas, line: 5356 "procedure TCustomForm.SetScaled(Value: Boolean);" finalization end. hug Edited December 16, 2020 by Guest Share this post Link to post
Uwe Raabe 2057 Posted December 16, 2020 23 minutes ago, emailx45 said: as in "csDesigning" verification, for me, do sense verify "csFreeNotification" too! as this action can be executed in many situations by many others actions, then, do sense, verify it. Are your with that? The docs about csFreeNotification say: Quote One or more other components have requested that this component notify them when it is destroyed. This flag is set when another component calls this component's FreeNotification method. That said, csFreeNotification is set when another component wants to be notified when the current component is destroyed. There is no specific action ongoing while csFreeNotification is set. In addition, csFreeNotification is only set but never unset. Share this post Link to post
Guest Posted December 16, 2020 (edited) the 21 minutes ago, Uwe Raabe said: Are your with that? The docs about csFreeNotification say: That said, csFreeNotification is set when another component wants to be notified when the current component is destroyed. There is no specific action ongoing while csFreeNotification is set. In addition, csFreeNotification is only set but never unset. the action was "already" executed! for sure, this "flag" is only for anyother "verify" if the object is alive! then, do sense consult it, else, do not sense consult "csDesigning" or "csLoading" if read all my code above, you would see my quote about "csFreeNotification" on HELP SYSTEM! Edited December 16, 2020 by Guest Share this post Link to post