Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: TFrame wont resize


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


Permlink Replies: 3 - Last Post: Sep 28, 2015 10:43 PM Last Post By: Bob Spencer
Bob Spencer

Posts: 26
Registered: 7/4/02
TFrame wont resize  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 6:15 PM
Hi

I have created a program that uses a TFrame to display data on a TTabitem and am having a problem getting the TFrame to resize when the main form does.
I have the frames being created dynamically when a clients records are loaded and at the point of creating them I set them to align to client (after their parent and owner are set)

Code extract here:
for X := 0 to CurrentProcedure.VisitsList.Count - 1 do
begin
AVisit := CurrentProcedure.VisitsList.VisitData[X];
aTab := TTabItem.Create(TabControl2);
atab.Name := 'ATab'+inttostr(x);
aTab.BeginUpdate;
aTab.Parent := TabControl2;
aTab.Text := AVisit.VisitStage + ' - ' + Datetostr(AVisit.VisitDate);
aTab.onResize := MyResize;
with TFrame1.Create(aTab) do
begin
//onResize := MyResize;
Parent := aTab;
locked := false;
//Anchors := [TAnchorKind.akLeft, TAnchorKind.akTop , TAnchorKind.akRight, TAnchorKind.akBottom];
height := 150;
FrameClient := CurrentClient;
FrameProcedure := CurrentProcedure;
FrameVisit := AVisit;
Visible := true;
name := 'aFrame' + inttostr(X);
//align := TAlignLayout.Client;
//
//Position.Y := 0; // atop;
Edit11.Text := AVisit.VisitStage;

I have also created my own resizing procedure and attached it to their individual procedures as follows.

procedure TPlannerForm.MyResize(Sender: TObject);
var
X: integer;
c: TOBJECT;
begin
for X := 0 to (Sender as TtabItem).componentcount-1 do
begin
c:= (Sender as TtabItem).components[X];
if c is TFrame then
with (c as TFrame) do
begin
BeginUpdate;
height := (Sender as TControl).height;
width := (Sender as TControl).width;
endUpdate;
end;
end;
end;

None of these work.
The frames are presented and their data is shown but I can not get them to resize.
I even put a button on the form that addresses each in turn and changes its dimensions and still nothing.

Now the really distressing part of this si that 2 weeks ago I actually solved this but after a hard drive failure I now cant recall what changes I made. I have been trying everything I can think of and nothing is working.
I'm suspecting that there is a setting that I may be missing in the TFrame or the owner control.

Can you shed any light on what I may be missing?
Eli M

Posts: 1,346
Registered: 11/9/13
Re: TFrame wont resize  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 9:21 PM   in response to: Bob Spencer in response to: Bob Spencer
My guess is that the objects are being set to the wrong Parent. Loop through the tab children and look for the real child object to parent to. Maybe put a button on the tab so you can find out what it's parent actually is.
Bob Spencer

Posts: 26
Registered: 7/4/02
Re: TFrame wont resize  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 10:08 PM   in response to: Eli M in response to: Eli M
Eli M wrote:
My guess is that the objects are being set to the wrong Parent. Loop through the tab children and look for the real child object to parent to. Maybe put a button on the tab so you can find out what it's parent actually is.

Thanks for the suggestion Eli
I have already tested that the tabitem that the frame sits on and is parented to is correct.
I have even just put a button on each frame that sets the width and height of the frame alone to 100 each and it still fails to make any difference.
When i'm in the design phase I can change the frame to align to client and it changes. Just not when dynamically created.
This leads me to believe that I am missing some setting when they are created.
Bob Spencer

Posts: 26
Registered: 7/4/02
Re: TFrame wont resize  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 10:43 PM   in response to: Bob Spencer in response to: Bob Spencer
Bob Spencer wrote:
Eli M wrote:
My guess is that the objects are being set to the wrong Parent. Loop through the tab children and look for the real child object to parent to. Maybe put a button on the tab so you can find out what it's parent actually is.

Thanks for the suggestion Eli
I have already tested that the tabitem that the frame sits on and is parented to is correct.
I have even just put a button on each frame that sets the width and height of the frame alone to 100 each and it still fails to make any difference.
When i'm in the design phase I can change the frame to align to client and it changes. Just not when dynamically created.
This leads me to believe that I am missing some setting when they are created.

Problem Solved.
Thanks for the point in the right Direction Eli you were right.
I changed the way the control is made and parented and it works now.
I cant explain why what I had before was wrong but hey, it works now and that's what counts.

aframe := TFrame1.Create(self);
with aframe do
begin
name := 'aFrame' + inttostr(X);
aframe.Parent := aTab;

Edited by: Bob Spencer on Sep 28, 2015 10:43 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02