SemperFudge
asked on
Accessing dynamically created frames stored in page control
hi,
this may be an easy question, but i can't figure it out.
i'm creating pages(frames) dynamically and storing them in a PageControl.
I need to be able to search the pagecontrol for the individual frame that i want
(searching by the caption) and then run a procedure on that frame that dynamically
creates a text box.
I am able to search and find the correct page, but i can't seem to access it to
run the procedure, any ideas?
Here is the code:
begin
i := 0;
cfound := false;
repeat
if (PageControl1.Pages[i].Cap tion = Category) then
begin
cfound := true;
end
else
begin
i := i + 1;
end;
until ((cfound = true)OR(i = PageControl1.PageCount-1)) ;
if (cfound = true) then
begin //found the category, place the new field in it
//PROBLEM HERE
//PageControl1.Pages[ i].
end//if
the code needs to go into the spot indicated.
I know i need to use PageControl.Pages[i] to indicate the page...but
PageControl.Pages[i].Proce dure(v); will not work.
any help is appreciated.
this may be an easy question, but i can't figure it out.
i'm creating pages(frames) dynamically and storing them in a PageControl.
I need to be able to search the pagecontrol for the individual frame that i want
(searching by the caption) and then run a procedure on that frame that dynamically
creates a text box.
I am able to search and find the correct page, but i can't seem to access it to
run the procedure, any ideas?
Here is the code:
begin
i := 0;
cfound := false;
repeat
if (PageControl1.Pages[i].Cap
begin
cfound := true;
end
else
begin
i := i + 1;
end;
until ((cfound = true)OR(i = PageControl1.PageCount-1))
if (cfound = true) then
begin //found the category, place the new field in it
//PROBLEM HERE
//PageControl1.Pages[
end//if
the code needs to go into the spot indicated.
I know i need to use PageControl.Pages[i] to indicate the page...but
PageControl.Pages[i].Proce
any help is appreciated.
ASKER
That's not excatly what i want to do.
I already have the code to add the control, it's a function in a frame...i want to call that function.
Here is the function i use to add a new Tab to my PageControl:
-------------------------- ---------- ----------
procedure TBlockFrame.NewTab(Sender: TObject;
var Name: string; var Value: string; var DataBlock: string;
var Category: string);
var
NewTabSheet: TTabSheet;
FFrame:TCIFFrame;
begin
NewTabSheet:= TTabSheet.Create(PageContr ol1);
//CREATE NEW CATEGORY TAB
with NewTabSheet do
begin
PageControl := PageControl1;
Visible := true;
Caption := Category;
PageControl1.ActivePage := NewTabSheet;
end;
FFrame := TCIFFrame.Create(NewTabShe et);
FFrame.Visible := false;
FFrame.Parent := NewTabSheet;
FFrame.NewField(Sender,Nam e,Value,Da taBlock);
FFrame.Align := alClient;
FFrame.Visible := true;
FFrame.BringToFront;
end;
-------------------------- ---------- ----------
That above function is called when i want to add a new tab and a new field in the new tab.
The function i included in my first post is one where i already have created the proper tab in the past, and i want to just call the function on the frame to add a new field to it.
in the above function, i call
FFrame.NewField(Sender,Nam e,Value,Da taBlock);
which calls the function in the frame to create the new field.
I want to be able to call this function from my original function (the one in my first post), but i can't figure out how to specify the frame asscociated with the tab.
I already have the code to add the control, it's a function in a frame...i want to call that function.
Here is the function i use to add a new Tab to my PageControl:
--------------------------
procedure TBlockFrame.NewTab(Sender:
var Name: string; var Value: string; var DataBlock: string;
var Category: string);
var
NewTabSheet: TTabSheet;
FFrame:TCIFFrame;
begin
NewTabSheet:= TTabSheet.Create(PageContr
//CREATE NEW CATEGORY TAB
with NewTabSheet do
begin
PageControl := PageControl1;
Visible := true;
Caption := Category;
PageControl1.ActivePage := NewTabSheet;
end;
FFrame := TCIFFrame.Create(NewTabShe
FFrame.Visible := false;
FFrame.Parent := NewTabSheet;
FFrame.NewField(Sender,Nam
FFrame.Align := alClient;
FFrame.Visible := true;
FFrame.BringToFront;
end;
--------------------------
That above function is called when i want to add a new tab and a new field in the new tab.
The function i included in my first post is one where i already have created the proper tab in the past, and i want to just call the function on the frame to add a new field to it.
in the above function, i call
FFrame.NewField(Sender,Nam
which calls the function in the frame to create the new field.
I want to be able to call this function from my original function (the one in my first post), but i can't figure out how to specify the frame asscociated with the tab.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that's exactly what i wanted, thanks!
Hi SemperFudge,
thanks for the flowers. Just some additional comments: Sometimes you want to avoid to maintain two seperate lists (MyList.Items[i] and PageControl1.Pages[i]) since it can cause alot of debugging. I am not sure but I guess there is a Tag property you can use:
FFrame := TCIFFrame.Create(NewTabShe et);
PageControl1.Pages[i].Tag := FFrame; // Typcast neccessary?
and
//PROBLEM HERE
//PageControl1.Pages[i]
TCIFFrame(PageControl1.Pag es[i].Tag) .Procedure (v);
Best of luck
J
thanks for the flowers. Just some additional comments: Sometimes you want to avoid to maintain two seperate lists (MyList.Items[i] and PageControl1.Pages[i]) since it can cause alot of debugging. I am not sure but I guess there is a Tag property you can use:
FFrame := TCIFFrame.Create(NewTabShe
PageControl1.Pages[i].Tag := FFrame; // Typcast neccessary?
and
//PROBLEM HERE
//PageControl1.Pages[i]
TCIFFrame(PageControl1.Pag
Best of luck
J
var
ed: TEdit;
/////
The code to found the page
/////
//YOUR PROBLEM
if (cfound = true) then
begin //found the category, place the new field in
ed:=TEdit.Create(Applicati
ed.parent:=PageControl1.Pa
ed.Left :=200;
ed.Top:=40;
//And you can set all the properties of ed Tedit
end//if
Explanation: Set the parent is the key
Let me know if you need something else.
Regards
Diego