Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TPanel.AutoSize does not work in XE6 Pro


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Jun 15, 2014 7:41 PM Last Post By: Linden ROTH
Marco Constant

Posts: 4
Registered: 5/3/06
TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 12, 2014 3:20 PM
I just upgrade to XE6 from XE4. The upgrade went pretty smooth. However, I have an issue with the TPanel. The program I am moving to XE6 uses a panel with option item in it. And in XE 4, as the items are visible/not visible the panel gets resized automatically. In XE 6, the AutoSize works in design, but at runtime it does not. This will require architecture change and I would rather not get there. Does anyone have a hint for me at where to look? Thanks
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 13, 2014 6:34 PM   in response to: Marco Constant in response to: Marco Constant
Marco Constant wrote:
I just upgrade to XE6 from XE4. The upgrade went pretty smooth. However, I have an issue with the TPanel. The program I am moving to XE6 uses a panel with option item in it. And in XE 4, as the items are visible/not visible the panel gets resized automatically. In XE 6, the AutoSize works in design, but at runtime it does not. This will require architecture change and I would rather not get there. Does anyone have a hint for me at where to look? Thanks

Appears to be more to it than you say (or can see) as a simple app in XE6 Pro works for me

{Code}
Panel1: TPanel;
Label1: TLabel;
Button1: TButton;

procedure TForm2.Button1Click(Sender: TObject);
begin
Label1.caption := Label1.caption + ' test'
end;

object Panel1: TPanel
Left = 224
Top = 104
Width = 33
Height = 15
AutoSize = True
Caption = 'Panel1'
TabOrder = 0
object Label1: TLabel
Left = 1
Top = 1
Width = 31
Height = 13
Caption = 'Label1'
end
end

{Code}

Does this work for you ?

Other ideas maybe - the has the panel got any margins / align stuff set the .DFM of your panel might help (and what it sitting on)

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Marco Constant

Posts: 4
Registered: 5/3/06
Re: TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2014 9:10 AM   in response to: Linden ROTH in response to: Linden ROTH
Linden

The example you were suggesting is not exactly the porblem I am having.

Let say, you have a TPanel Panel1. Inside of it, you place a text TLabel Label and a button TButton Button.

Panel1 has the AutoSize set to True,

The Panel has the default anchor Top Right. No other alignment.

Label has the alignment to Left and is the first one in the panel.

Button has also the alignment to Left.

By default Label and Button are visible.

When you click on the button, the label Visible property is toggle between True and False. Which should resize the panel as the number of element visible decrease/increase.

This has been working for 1 year now under XE4.

With XE6, the panel does not resize. It remains at the original size where both the label and the button are visible.

    Panel1: TPanel;
    Label1: TLabel;
    Button1: TButton;
 
procedure TfrmSLMain.Button1Click(Sender: TObject);
begin
    label1.Visible := not label1.Visible;
end;


The DFM content is:

  object Panel1: TPanel
    Left = 359
    Top = 17
    Width = 112
    Height = 73
    AutoSize = True
    Caption = 'Panel1'
    TabOrder = 2
    object Label1: TLabel
      Left = 1
      Top = 1
      Width = 35
      Height = 71
      Align = alLeft
      Caption = 'Label1 '
      ExplicitHeight = 13
    end
    object Button1: TButton
      Left = 36
      Top = 1
      Width = 75
      Height = 71
      Align = alLeft
      Caption = 'Button1'
      TabOrder = 0
      OnClick = Button1Click
      ExplicitLeft = 0
      ExplicitTop = 29
      ExplicitHeight = 25
    end
  end


Edited by: Marco Constant on Jun 15, 2014 12:11 PM
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2014 4:23 PM   in response to: Marco Constant in response to: Marco Constant
Marco Constant wrote:
Linden

The example you were suggesting is not exactly the porblem I am having.

Let say, you have a TPanel Panel1. Inside of it, you place a text TLabel Label and a button TButton Button.

Panel1 has the AutoSize set to True,

The Panel has the default anchor Top Right. No other alignment.

Label has the alignment to Left and is the first one in the panel.

Button has also the alignment to Left.

By default Label and Button are visible.

When you click on the button, the label Visible property is toggle between True and False. Which should resize the panel as the number of element visible decrease/increase.

This has been working for 1 year now under XE4.

With XE6, the panel does not resize. It remains at the original size where both the label and the button are visible.
Ok couple of things

There is some serious 1/2 arsed code inside VCL.Controls FAlignControlList and LAlignedControlList seriously took me 5 mins to realize they were different variables - I wouldn't be happy with this code myself looks very "Patched"

And your visible := not visible is funny in the button click as it'll never happen that the button will click on invisible - well not naturally :) - just having a good morning

Seriously don't know why it work in XE4 but you can fix it quickly in XE6 with the following code

unit Unit2;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
 
type
  TMyPanel = class( TPanel )
    procedure ControlsAligned; override; ///////Here
  end;
 
  TPanel = class( TMyPanel );
 
  TForm2 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form2: TForm2;
 
implementation
 
{$R *.dfm}
 
procedure TForm2.Button1Click(Sender: TObject);
begin
  Button1.Visible := false;
end;
 
{ TMyPanel }
 
procedure TMyPanel.ControlsAligned;
begin
  inherited;
  AdjustSize;  //Here
end;
 
end.

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Marco Constant

Posts: 4
Registered: 5/3/06
Re: TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2014 6:59 PM   in response to: Linden ROTH in response to: Linden ROTH

And your visible := not visible is funny in the button click as it'll never happen that the button will click on invisible - well not naturally :) - just having a good morning

Actually, the example I gave was to toggle the visible property of the Label1, not the button.


Seriously don't know why it work in XE4 but you can fix it quickly in XE6 with the following code

So should I enter a Bug somewhere? I never brought up a Bug before. But I really think this is a bug.


unit Unit2;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
 
type
  TMyPanel = class( TPanel )
    procedure ControlsAligned; override; ///////Here
  end;
 
  TPanel = class( TMyPanel );
 
  TForm2 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form2: TForm2;
 
implementation
 
{$R *.dfm}
 
procedure TForm2.Button1Click(Sender: TObject);
begin
  Button1.Visible := false;
end;
 
{ TMyPanel }
 
procedure TMyPanel.ControlsAligned;
begin
  inherited;
  AdjustSize;  //Here
end;
 
end.

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Your example above may solve the problem but it requires to overload the function, which mean I now need to control it by code. I do not really want to do that. But thank you for the work around.

Thanks for looking into this
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: TPanel.AutoSize does not work in XE6 Pro  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2014 7:41 PM   in response to: Marco Constant in response to: Marco Constant
Marco Constant wrote:

And your visible := not visible is funny in the button click as it'll never happen that the button will click on invisible - well not naturally :) - just having a good morning

Actually, the example I gave was to toggle the visible property of the Label1, not the button.

DOH!



Seriously don't know why it work in XE4 but you can fix it quickly in XE6 with the following code

So should I enter a Bug somewhere? I never brought up a Bug before. But I really think this is a bug.

Regression at least

QC http://qc.embarcadero.com/ or C:\Program Files (x86)\Embarcadero\Studio\14.0\QualityCentral\QualityCentral.exe

Your example above may solve the problem but it requires to overload the function, which mean I now need to control it by code. I do not really want to do that. But thank you for the work around.

Thanks for looking into this

In XE6 something like my suggestion will be required ... not sure what the problem is with "control it by code" as I didn't think there was any other way

BTW this fix only needs to be done once to work in all you program ... just needs to be referenced correctly

--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02