Ok, I am writing an IRC client. Each IRC channel that the user is in will be a new tab (using TPageControl). Now, how do I create a new tab when a certain event is triggered? The tab would have to contain the same listboxes and all as the original tab (I created the original tab at design time). Any help would be great, I've been hammering at this all night and can't figure it out.
If you know how to do it using TTabControl please share that with me as well.
Thanks.
Comments
But if you use a TTabControl you will have to share components, meaning the text from the current channel can be shown in your TRichEdit or TMemo (or whatever) but the other hidden channels' text will have to be stored in memory. Likewise for the nicklist, topic, channel modes, etc..
Anyway, heres how you use both:
TPageControl - This is straight out of the help file from the TPageControl.Pages screen:
Note: Pages is a read-only property. To add a tab sheet to a page control at design time, right click and select New Page. To add a tab sheet to a page control at runtime, create the tab sheet and set its PageControl property to the page control.
And TTabControl. Didnt need to look in the help file for this one. TTabControl.Tabs is a TString, so you use TTabControl.Tabs.Add('#somechannel') to add a new tab.
: Ok, I am writing an IRC client. Each IRC channel that the user is in will be a new tab (using TPageControl). Now, how do I create a new tab when a certain event is triggered? The tab would have to contain the same listboxes and all as the original tab (I created the original tab at design time). Any help would be great, I've been hammering at this all night and can't figure it out.
:
: If you know how to do it using TTabControl please share that with me as well.
:
: Thanks.
:
procedure TForm1.Button1Click(Sender: TObject);
var
NewTabSheet: TTabSheet;
C:TControl;
i:integer;
begin
NewTabSheet:=TTabSheet.Create(PageControl1);
//NOTE - I would have never guessed this!
NewTabSheet.PageControl:=PageControl1;
NewTabSheet.Name:='TabSheet'+IntToStr(PageControl1.PageCount);
NewTabSheet.Caption:=NewTabSheet.Name;
// This next trick ( called "cloning" ) was adapted from
// Marco Cantu's "Delphi Developer's Guide"
for i:=0 to TabSheet1.ControlCount-1 do begin
C:=TabSheet1.Controls[i];
with TControlClass(C.ClassType).Create(NewTabSheet) do begin
Parent:=NewTabSheet;
SetBounds(C.Left,C.Top,C.Width,C.Height);
// Need to add your other Properties and Events here...
end;
end;
end;
It solved all mine. Ive been working on an IRC client for awhile now. To get the project going, I set it up as a single window client. Although Im not using the "cloning" technique, it got me off in the right direction, and Ive finally cleared the last hurdle. (It was the typecasting examples from your code that helped)
Thanks
:
: procedure TForm1.Button1Click(Sender: TObject);
: var
: NewTabSheet: TTabSheet;
: C:TControl;
: i:integer;
: begin
: NewTabSheet:=TTabSheet.Create(PageControl1);
:
: //NOTE - I would have never guessed this!
: NewTabSheet.PageControl:=PageControl1;
:
: NewTabSheet.Name:='TabSheet'+IntToStr(PageControl1.PageCount);
: NewTabSheet.Caption:=NewTabSheet.Name;
:
: // This next trick ( called "cloning" ) was adapted from
: // Marco Cantu's "Delphi Developer's Guide"
: for i:=0 to TabSheet1.ControlCount-1 do begin
: C:=TabSheet1.Controls[i];
: with TControlClass(C.ClassType).Create(NewTabSheet) do begin
: Parent:=NewTabSheet;
: SetBounds(C.Left,C.Top,C.Width,C.Height);
:
: // Need to add your other Properties and Events here...
:
: end;
: end;
:
: end;
:
:
:
:
12 Years later, it helped me!!
12 Years later, it helped me!!
[URL="http://www.iphonecasepackaging.com"]iPhone case packaging[/URL]