Forum > General

Resize

(1/4) > >>

Paolo:
Hello,

probably I am confused how resize works !
here what I see:
In one application of mine I have a lot of graphical elements (3D, chart, XY-plot, etc... all derived by TGrpahicControl) placed on different tabs of a TPageControl.
I noticed, but this seems not happening in the delphi version, that there is a large time-lag in updating the tab content when switching among them (well visible).
After some investigation I have understood that the "resize" is fired for all the graphical elements placed on the application (even regardeless the tab is visible or not and nothing is really "resized"), this causes a lot of repaint of them becaues they have their "resize" procedure implemented that fire the repaint.
Trying to isolate the problem I prepare the code here attached (Self standing compilable), I see the "TXY component" Resize is called not only if the main form is resized bue even if just click on the button (top left on the toolbar) that show the "resize" counter continuosly growing !
I was expecting for TXYcomponent "resize" was fired just if the component change Size, but it seems not the case.
Wath did I miss ?
This justify in LAZ+FPC the time-lag, but I do not understand the meaning of resize

when I run the attache code at first click on the button I see alerdy 5 call to resize ! then for any further click the counter increases by 1

win 10 pro, laz+FPC 2.2.0+3.2.2


--- 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";}};} ---  TXY = class(TGraphicControl)  public    procedure Resize; override;    procedure Paint; override;  end;   TForm1 = class(TForm)    Edit3: TEdit;    ToolBar21: TToolBar;    ToolButton4: TToolButton;    procedure FormCreate(Sender: TObject);    procedure ToolButton4Click(Sender: TObject);  private   public    pippo : TXY;  end; var  Form1: TForm1;  drawcount : integer; implementation {$R *.lfm} { TXY } procedure TXY.Resize;begin  inherited Resize;  beep;  //for "feedback"  drawcount:=drawcount+1; //counter of resize callend; procedure TXY.Paint;begin  inherited Paint;  canvas.Brush.Color:=clBlue;  Canvas.Rectangle(0, 0, width-1, height-1);end; { TForm1 } procedure TForm1.ToolButton4Click(Sender: TObject);begin  edit3.text:=drawcount.tostring;end; procedure TForm1.FormCreate(Sender: TObject);begin  pippo:=TXY.Create(Self);  Pippo.Parent:=Self;  pippo.Top:=1;  pippo.Left:=1;  pippo.Width:=100;  pippo.height:=100;  pippo.Visible:=true;end; initialization  drawcount:=0;  //it should be not necessaryend. 

Paolo:
just tested my application on
laz-fpc 2.0.12+3.2.0 it is faster, even if coming back on the tab with graphical elements it tooks a lot to be repainted even if it shouldn't repainted at all (nothing is changed), still resize is fired a lot of time!

wp:
Putting a breakpoint in your Resize method and calling the stack trace leads me to TWinControl.RealSetText which contains an unconditional call to AdjustSize. In my understanding AdjustSize performs the AutoSize action. Of course, your Edit displaying the counter value has no AutoSize, and I wonder whether there should not be an "if AutoSize then" in front of the AdjustSize. Doing this, in fact, silences the counter.

I am not sure however, whether this is the correct solution since it might have many side-effects.

Since your application seems to be rather complex, I'd ask you to open file "wincontrol.inc" (in (lazarus)/lcl/include), find this procedure and replace the AdjustSize as follows

--- 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  // <--- added      AdjustSize;  ... Rebuild the IDE ("Tools" > "Build Lazarus with profile..."). Then test and check whether it solves the issue (it should) and - more importantly - has any sideeffects on toolbars, ChildSizing, anchoring, align etc.

Paolo:
thanks wp, I'll try as soon as possible your suggestion.
But what is the link between "RealSetText" (of which control in my code ?) and my Resize of TXY class in my code ?
I just perss the toolbutton and I see fired the TXXY.Resize ???

thanks again. (later I'll report if the patch you suggest it is ok or not)

wp:
The issue is not in the click, but in the change of the Edit.Text. When you set the Edit.Text to the new value of the resize counter RealSetText is called internally, and this calls AdjustSize which triggers a call to Resize.

As a test, activate a text console (in Windows uncheck "Win32 gui application" in the project options ("Config and Target"), and replace the "edit3.Text := drawcount.toString" by a "WriteLn(drawcount)". You will see that the displayed number in the console does NOT change after clicking.

Navigation

[0] Message Index

[#] Next page

Go to full version