[SOLVED]TShape is not resized after Parent Panel resizing lazarus / 31-LCL ---------------------------------------------------------------------- Bruce44 · 2016-10-03 17:53 Hi I have a TShape comp inside a TPanel. I try to set TShape position (Top, Left) and size (Width, Height) inside the onResize event of the panel (panel is resized itself by code inside the OnResize event of the form). The event is called, but any of the Left,Top,Width, Height has an effect on the TShape comp. If I installed a TStaticText or a TEdit inside the same panel, it works. More strange, even without the Resize event, if I set Anchors set on TShape, It doesn't make it resized when parent panel is resized (it works with other component types) It doesn't work also if I resize it directly from the OnResize event of the form (after panel size has been changed just before) ---------------------------------------------------------------------- Handoko · 2016-10-03 18:02 Can you please post you code here? And it will be better if you provide more info: screenshots, Lazarus version, OS, etc. ---------------------------------------------------------------------- Bruce44 · 2016-10-03 19:14 I made a simple test from an empty project in order to check if this problem still happens : A main form, a TPanel on it, a TShape inside the TPanel with anchors akBottom and akTop, and a button to resize the Panel But the bug doesn't occur in that case : when I resize the panel by code when pressing the button, the TShape inside the TPanel is automatically resized. In my app, the  form containing the TPanel and the TShape inside is embedded inside one panel which is embedded itself in the Main Form. I will investigate more... ---------------------------------------------------------------------- wp · 2016-10-03 19:56 Quote from: Bruce44 on October 03, 2016, 07:53:37 pmpanel is resized itself by code inside the OnResize event of the formDo I understand correctly: In the OnResize event handler you call something which resizes the control again? Sounds very risky because the called Resize will trigger another OnResize event which will resize the control again etc. If the system does not crash this is a very unpredictable situation at least. ---------------------------------------------------------------------- molly · 2016-10-03 20:33 Quote from: Bruce44 on October 03, 2016, 07:53:37 pmI have a TShape comp inside a TPanel. I try to set TShape position (Top, Left) and size (Width, Height) inside the onResize event of the panel (panel is resized itself by code inside the OnResize event of the form). The event is called, but any of the Left,Top,Width, Height has an effect on the TShape comp. I take it there is a typo there in that you meant nothing is happening. Now you wrote _has an effect_ (which is normal behaviour). QuoteIf I installed a TStaticText or a TEdit inside the same panel, it works. It is unclear what works or what does not work. e.g. the colour of my handbag is ugly. QuoteMore strange, even without the Resize event, if I set Anchors set on TShape, It doesn't make it resized when parent panel is resized (it works with other component types) It doesn't work also if I resize it directly from the OnResize event of the form (after panel size has been changed just before) I can resize a shape manually based on a panel resize event. works perfectly for me. If i let the shape occupy client are it also resizes as expected. Please state OS and Lazarus version and pretty very pretty please if it suits you, show us some code. ---------------------------------------------------------------------- Bruce44 · 2016-10-03 21:44 Quote from: wp on October 03, 2016, 09:56:07 pmQuote from: Bruce44 on October 03, 2016, 07:53:37 pmpanel is resized itself by code inside the OnResize event of the formDo I understand correctly: In the OnResize event handler you call something which resizes the control again? Sounds very risky because the called Resize will trigger another OnResize event which will resize the control again etc. If the system does not crash this is a very unpredictable situation at least. No. In the OnResize event of the form, I change the Height of the Panel. There is no recursive call. But TShape controls inside this Panel are not resized automatically according to their anchors properties or if I set any of the Height, Top, Left, Width property of these TShape to another value (still from the OnResize event of the Form). Other controls types included in this panel are correctly resized (TPanel, TStaticText, ...). ---------------------------------------------------------------------- Bruce44 · 2016-10-03 22:19 Wrong alert ! After analyzing the source code of one of the libraries provided with the appli, it appears that all TShape controls are reset to their original positions when resized. So there is no LAZARUS bug, as I suspected it before, but just a programmer's bug ! Sorry for the disturb ! Is there a way to delete this complete post ? Because this one has no use indeed ! ---------------------------------------------------------------------- wp · 2016-10-03 22:20 Why don't you write a simple demo which shows the issue? Then everybody knows what you are talking about (only pas, lfm, lpi and lpr files, packed together in a single zip). ---------------------------------------------------------------------- Bruce44 · 2016-10-03 22:51 "Solved" See reply#6 ---------------------------------------------------------------------- Zath · 2016-10-04 00:26 Wouldn't it be better to use the OnPaint event of the panel to redraw the shape after the resize ? ---------------------------------------------------------------------- molly · 2016-10-04 01:05 Quote from: Zath on October 04, 2016, 02:26:38 amWouldn't it be better to use the OnPaint event of the panel to redraw the shape after the resize ? Why ? Code: [Select]procedure TForm1.Panel1Resize(Sender: TObject); begin   Shape1.SetBounds(10,10,Panel1.Width - 20, Panel1.Height - 20); end; And the shape will repaint itself using the new size.