Delphi XE6 TForm.AutoSize - delphi

I've code in Delphi XE2 who work perfectly. But in Delphi XE6 it doesn't work.
I create a Tform with the property AutoSize to true. I use a TPanel align alTop with a button for create some another panels.
procedure TForm2.Button1Click(Sender: TObject);
var
t :TPanel;
begin
t := TPanel.Create(self);
t.Parent := self;
t.Align := alTop;
end;
The form doesn't auto size. If I want to see all my panels I have to move the form (or try to resize, ....).
Have you any idea's ?

This is indeed a change in behaviour. I can reproduce what you report. Namely that your code results in the form size changing in XE2, but not in XE6.
To work around this you can manually call AdjustSize:
procedure TForm1.Button1Click(Sender: TObject);
var
Panel: TPanel;
begin
Panel := TPanel.Create(self);
Panel.Parent := Self;
Panel.Top := ClientHeight;
Panel.Align := alTop;
AdjustSize;
end;

Not align, use anchors:
t.Anchors:=[TAnchorKind.akTop];
This is from my XE5 (have no XE6)

Related

Is it possible to have working OnClick event for TGlyph in FMX?

I just put an instance of TGlyph on a FMX Form and tested this code.
procedure TForm1.FormCreate(Sender: TObject);
begin
Glyph1.OnClick:=myClick;
end;
procedure TForm1.myClick(Sender: TObject);
begin
ShowMessage('test');
end;
Nothing happening when I click the glyph. I know that there is no OnClick event for TGlyph in the Designer IDE. But this TGlyph has derived from TControl which has OnClick. I know that I can use TImage instead of TGlyph but I am just curiuse about that.
You have to set
Glyph1.HitTest := true;
to make it work.

How to maximize a form in a Tpanel using delphi

i'm trying to dynamically show a form in a TPanel
using this function
procedure Show_form_in_panel(form: TForm; Panel: Tpanel);
begin
form.Parent := Panel;
form.Show;
form.WindowState := wsMaximized;
end;
the form is showing very normal but he's not maximized in my panel and also i want to make this form automaticly react like components that have the Alight property = (alClient)
I want to make this form automatically react like components that have the Align property set to alClient.
That's the solution. Remove
form.WindowState := wsMaximized;
and replace with
form.Align := alClient;

Let components dropped on my control in the IDE become children of my control

I have a descendant of TWinControl (in fact it is just that for now) and I registered it as a component in the IDE:
type
TGroupPanel = class(TWinControl);
But when I drop other components on it, they attach to the form instead of to my control. In other words, I want my custom control to behave like a TPanel so that components dropped on it become its children.
If I create the components at runtime and assign them manually to my control, like in the code below, then it works:
TForm1 = class(TForm)
Group: TGroupPanel;
procedure FormCreate(Sender: TObject);
private
Panel: TPanel;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel := TPanel.Create(Group);
Panel.Parent := Group;
Panel.Align := alClient;
end;
So, what should I do to get components dropped on a TWinControl at design time become children of that control?
(What I am trying to do is to make a special control to group other components on, so I can align and position them together. Of course, I can do that with a normal panel, but I want to do this with a lightweight control that does not paint anything, and in TWinControl I found the solution.)
Set csAcceptControls flag for ControlStyle.
constructor TGroupPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csAcceptsControls];
end;

Mouseover Image On Buttons In FMX XE2

How to make a mouseover image for button ?
I used to make in FMX 2 buttons, and fill it with bitmap. But its owful .
I found property IsMouseOver
procedure TForm1.Button1Paint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
begin
if Button1.IsMouseOver then
begin
Button1.Text:='yes';
end
else
begin
Button1.Text:='nono';
end;
end;
But , i realy dont understand how to use containers, i only want to change fill ( my bitmap) by the method written before. Can someone give a simple code?
Or maybe its easier to make in VCL ?
Put two separate TImage controls on the button (drag them onto the button in the Structure View):
Size them to fit the button, and give each a separate image using the MultiResBitmap property editor.
Create an event handler for one of the TImage components for the OnMouseEnter and OnMouseLeave events, and then assign those handlers to both of the TImage components:
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
Image1.Visible := False;
Image2.Visible := True;
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
Image1.Visible := True;
Image2.Visible := False;
end;

How can I scroll the content of a TFlowPanel?

Delphi implementation of the TFlowPanel control seems to lack an important feature of the C# version, the AutoScroll one.
The C# control with AutoWrap= False and AutoScroll=True behave like a horizontal scrollable list of controls.
How can i mimic the behavior of the C# version of the control ?
Thanks,
Alin
P.S.
I know i can use TScrollBox to get this behavior but TFlowPanel (in the not crippled version) allow for much more flexibility.
Create your TFlowPanel inside a TScrollBox, with the following properties:
Align : alLeft
AutoSize : TRUE
AutoWrap : FALSE
That should get you the behaviour you are after I think.
If you want to scroll vertically set
FlowPanel1.Align := alTop;
FlowPanel1.AutoSize := True;
FlowPanel1.AUtoWrap := False;
For people who are looking for a working vertical scrolling method:
procedure TfrmSample.FixVerticalScroll(const AFloatPanel: TFloatPanel);
begin
fFloatPanel.Align := alTop;
fFloatPanel.AutoSize := True;
fFloatPanel.AutoWrap := True;
fFloatPanel.OnResize := OnFlowPanelResize;
end;
procedure TfrmSample.OnFlowPanelResize(Sender: TObject);
begin
// Fix: otherwise panel is not operating on the full width
fFloatPanel.Align := alClient;
fFloatPanel.Align := alTop;
end;

Resources