Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
Using TPageControl, how do I create a new page at run time? Posted by Jason Caughran on 23 Aug 2000 at 11:22 PM
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.<br>
<br>
If you know how to do it using TTabControl please share that with me as well. <br>
<br>
Thanks.


Edit Report
Re: Using TPageControl, how do I create a new page at run time? Posted by Manning on 24 Aug 2000 at 1:14 PM
Both a TPageControl and TTabControl would work. Buth both will require a little planning. If you use a TPageControl you will have to create and destroy a few components as a user joins/parts a channel. <br>
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..<br>
<br>
Anyway, heres how you use both:<br>
<br>
TPageControl - This is straight out of the help file from the TPageControl.Pages screen:<br>
<br>
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.<br>
<br>
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.<br>
<br>
: 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.<br>
: <br>
: If you know how to do it using TTabControl please share that with me as well. <br>
: <br>
: Thanks.<br>
: <br>
<br>



Edit Report
Re: Using TPageControl, how do I create a new page at run time? Posted by Jeff P. on 24 Aug 2000 at 1:30 PM
// I doubt if this will solve all your problems, but it might be a start:<br>
<br>
procedure TForm1.Button1Click(Sender: TObject);<br>
var<br>
NewTabSheet: TTabSheet;<br>
C:TControl;<br>
i:integer;<br>
begin<br>
NewTabSheet:=TTabSheet.Create(PageControl1);<br>
<br>
//NOTE - I would have never guessed this!<br>
NewTabSheet.PageControl:=PageControl1;<br>
<br>
NewTabSheet.Name:='TabSheet'+IntToStr(PageControl1.PageCount);<br>
NewTabSheet.Caption:=NewTabSheet.Name;<br>
<br>
// This next trick ( called "cloning" ) was adapted from<br>
// Marco Cantu's "Delphi Developer's Guide"<br>
for i:=0 to TabSheet1.ControlCount-1 do begin<br>
C:=TabSheet1.Controls[i];<br>
with TControlClass(C.ClassType).Create(NewTabSheet) do begin<br>
Parent:=NewTabSheet;<br>
SetBounds(C.Left,C.Top,C.Width,C.Height);<br>
<br>
// Need to add your other Properties and Events here...<br>
<br>
end;<br>
end;<br>
<br>
end;<br>
<br>
<br>



Edit Report
Re: Re: Using TPageControl, how do I create a new page at run time? Posted by Manning on 25 Aug 2000 at 1:08 PM
: // I doubt if this will solve all your problems, but it might be a start:<br>
<br>
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)<br>
<br>
Thanks<br>
<br>
: <br>
: procedure TForm1.Button1Click(Sender: TObject);<br>
: var<br>
: NewTabSheet: TTabSheet;<br>
: C:TControl;<br>
: i:integer;<br>
: begin<br>
: NewTabSheet:=TTabSheet.Create(PageControl1);<br>
: <br>
: //NOTE - I would have never guessed this!<br>
: NewTabSheet.PageControl:=PageControl1;<br>
: <br>
: NewTabSheet.Name:='TabSheet'+IntToStr(PageControl1.PageCount);<br>
: NewTabSheet.Caption:=NewTabSheet.Name;<br>
: <br>
: // This next trick ( called "cloning" ) was adapted from<br>
: // Marco Cantu's "Delphi Developer's Guide"<br>
: for i:=0 to TabSheet1.ControlCount-1 do begin<br>
: C:=TabSheet1.Controls[i];<br>
: with TControlClass(C.ClassType).Create(NewTabSheet) do begin<br>
: Parent:=NewTabSheet;<br>
: SetBounds(C.Left,C.Top,C.Width,C.Height);<br>
: <br>
: // Need to add your other Properties and Events here...<br>
: <br>
: end;<br>
: end;<br>
: <br>
: end;<br>
: <br>
: <br>
: <br>
: <br>
<br>



Report
Re: Using TPageControl, how do I create a new page at run time? Posted by heinduplessis on 23 Jan 2012 at 1:35 AM
hehe

12 Years later, it helped me!!
Report
Re: Using TPageControl, how do I create a new page at run time? Posted by heinduplessis on 23 Jan 2012 at 1:39 AM
hehe

12 Years later, it helped me!!
Report
Re: Re: Using TPageControl, how do I create a new page at run time? Posted by maomen on 15 Mar 2012 at 1:17 AM
Everybody is good, we will discuss.
Report
Re: Re: Using TPageControl, how do I create a new page at run time? Posted by maomen on 15 Mar 2012 at 1:23 AM
Everybody is good, we will discuss.
Report
Re: Using TPageControl, how do I create a new page at run time? Posted by utalk2010 on 16 Jun 2012 at 1:03 AM
iPhone case packaging

[URL="http://www.iphonecasepackaging.com"]iPhone case packaging[/url]



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.