?
Solved

Accessing dynamically created frames stored in page control

Posted on 2003-03-12
5
Medium Priority
?
277 Views
Last Modified: 2010-04-04
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].Caption = 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].Procedure(v); will not work.
any help is appreciated.
0
Comment
Question by:SemperFudge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Expert Comment

by:DiegoC
ID: 8124394
This is what you need?:

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(Application);
     ed.parent:=PageControl1.Pages[i];
     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


0
 

Author Comment

by:SemperFudge
ID: 8124634
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(PageControl1);
  //CREATE NEW CATEGORY TAB
  with NewTabSheet do
  begin
    PageControl := PageControl1;
    Visible := true;
    Caption := Category;
    PageControl1.ActivePage := NewTabSheet;
  end;

  FFrame := TCIFFrame.Create(NewTabSheet);
  FFrame.Visible := false;
  FFrame.Parent := NewTabSheet;

  FFrame.NewField(Sender,Name,Value,DataBlock);

  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,Name,Value,DataBlock);
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.





0
 
LVL 2

Accepted Solution

by:
j42 earned 280 total points
ID: 8126509
Hi SemperFudge,

You can use a TList to store a reference of the frame. Once you got the index of the PageControl.Page you can get the frame.

----------------------------------------------
procedure TBlockFrame.NewTab(Sender: TObject;
   var Name: string; var Value: string; var DataBlock: string;
   var Category: string);
...
FFrame := TCIFFrame.Create(NewTabSheet);
MyList.Add(FFrame);   // ************** NEW CODE ***********

----------------------------------------------
if (cfound = true) then
begin   //found the category, place the new field in it      
    //PROBLEM HERE
    //PageControl1.Pages[i]
  TCIFFrame(MyList.Items(i)).Procedure(v);  // ******** NEW CODE ****



Regards
J
0
 

Author Comment

by:SemperFudge
ID: 8132766
that's exactly what i wanted, thanks!
0
 
LVL 2

Expert Comment

by:j42
ID: 8134776
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(NewTabSheet);
PageControl1.Pages[i].Tag := FFrame; // Typcast neccessary?

and

//PROBLEM HERE
//PageControl1.Pages[i]
TCIFFrame(PageControl1.Pages[i].Tag).Procedure(v);

Best of luck
J
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question