Forum > General

Resize

<< < (2/4) > >>

Paolo:
recompiled lazarus, ma no effects on the code, I did:

locate "wincontrol.inc" (in (lazarus)/lcl/include)
open with text editor,
applied the correction you suggest
Rebuild the IDE ("Tools" > "Build Lazarus with profile : Normal")

but it seems nothing is changed !

Paolo:
@wp,


--- Quote ---your Edit displaying the counter value has no AutoSize

--- End quote ---

edit has autosize !

I make Edit3.autosize:=false; and after clicking the button the counter does not inrement.

but in the attached code where I put a TPAgecontrol as per my application I still see the problem

wp:

--- Quote from: Paolo on June 25, 2022, 07:02:56 pm ---@wp,


--- Quote ---your Edit displaying the counter value has no AutoSize

--- End quote ---

edit has autosize !

--- End quote ---
Sorry, I got confused because I did also other tests. Without the modification in the RealGetSize method, the counter incremented even when the form caption was used to display the value rather than the edit.

But that's not the problem...

I did some more tests: Added a TPanel (or a TPaintbox for a TCustomControl) and put your ResizeCounter into the OnResize event. Notice that here the counter does NOT increment! Having this in mind, I used the debugger to step into the inherited Resize instruction of your TXY component; it leads immediately to the inherited TControl.Resize:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TControl.Resize;begin  if ([csLoading,csDestroying]*ComponentState<>[]) then exit;  if AutoSizeDelayed then exit;                    // <-------------- Here the procedure is exited.   if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height)  or (FLastResizeClientWidth<>ClientWidth)  or (FLastResizeClientHeight<>ClientHeight) then begin    {if CompareText('SubPanel',Name)=0 then begin      DebugLn(['[TControl.Resize] ',Name,':',ClassName,      ' Last=',FLastResizeWidth,',',FLastResizeHeight,      ' LastClient=',FLastResizeClientWidth,',',FLastResizeClientHeight,      ' New=',Width,',',Height,      ' NewClient=',ClientWidth,',',ClientHeight]);      DumpStack;    end;}    FLastResizeWidth:=Width;    FLastResizeHeight:=Height;    FLastResizeClientWidth:=ClientWidth;    FLastResizeClientHeight:=ClientHeight;    DoOnResize;  end;end;
Stepping through the code line by line, it can be seen that the method is already exited in the 2nd line, "if AutoSizeDelayed then exit". So, the bulk of the method is not executed, it cannot be the cause of your performance issues.

Of course, if your own components implement their own Resize methods this code will be executed, and depending on what it is doing it can cause some noticeable delay. To prevent this you should do the same as TControl.Resize: Put an "if AutoSizedelayed then exit" before your code (AutoSizeDelayed is a public method of TControl and thus accessible to all controls):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TXY.Resize;begin  inherited;  if AutoSizeDelayed then exit;  // here should be your code, e.g. drawcount := drawcount+1;end;

Paolo:
thank wp,

tommorow I'll check your suggestion.

have I to remove the previously added line in wincontrol.inc


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TWinControl.RealSetText(const AValue: TCaption);...    if AutoSize then  // <--- Have I to remove this line ?      AdjustSize;  ...

Martin_fr:
Are we sure that

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TWinControl.RealSetTextis never called for anything that changes it's size, regardless of the "AutoSize" property?

E.g. something like the text on a tab of a pagecontrol? Ok, that would have to lead to wrapping or similar, before it affects other components. And then it might trigger resized via other means.

Anyway, another case.

Put a (or several) label (label.autosize := false)
on a panel (panel.autosize = true)

Enable ChildSizing on the panel
LeftToRight
2 per line
no changes to Enlarge../Shrink...

Changing the label.caption will change the size of the label and panel.
Yes, weird... Should it? No idea... But it does. (Laz 2.3)

AutoSizeDelayed
Afaik that simply means that some outer caller is holding it back, but that when the execution returns to the outer caller it will be run.





--- Quote ---I did some more tests: Added a TPanel (or a TPaintbox for a TCustomControl) and put your ResizeCounter into the OnResize event. Notice that here the counter does NOT increment
--- End quote ---

Yet, that does not mean that the AutoSize code doesn't run.
In
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TControl.Resize; the OnResize event is only called, if the computation of the AutoSize code actually made changes.

Yet of course, you are right, such checks should be done by any inherited code too.
Especially if that inherited code will cause repainting of the control.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TControl.Resize;begin  if ([csLoading,csDestroying]*ComponentState<>[]) then exit;  if AutoSizeDelayed then exit;   if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height)  or (FLastResizeClientWidth<>ClientWidth)  or (FLastResizeClientHeight<>ClientHeight) then begin..........    DoOnResize;  end;end; 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version