Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new tab on TTabSheet at runtime

Status
Not open for further replies.

adrianjohnson

Programmer
May 16, 2002
145
GB
I've decided to have a play with Borland Turbo C++, and decided to write a multi-tab web browser (to help me understand the language, IDE etc.)

I've added a TPageControl to the form, with a TTabSheet, plus a button which I would like to use to add a new tab, with a web browser control in it.

I've managed to get it to add a new tab, but it won't add the web browser control. The code I have is below:

Code:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TTabSheet *pTabSheet = new TTabSheet(PageControl1);
pTabSheet->PageControl = PageControl1;
pTabSheet->Caption = "New Tab";

TWebBrowser * MyWebBrowser = new TWebBrowser(pTabSheet);
//Parent code
MyWebBrowser->Visible = true;
PageControl1->ActivePage = pTabSheet;
}

The line that says:

Code:
//Parent code

is the bit where I've tried to make the Tab Sheet or the Page Control the parent of the web browser, but it produces an error.

How can I get this to work?

Thanks,

Adrian
 
Did you get this to work? If not, what was the error?


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Yes, I did manage to get it to work. Here's the code:

Code:
TWebBrowser * MyWebBrowser = new TWebBrowser(pTabSheet);
pTabSheet->InsertControl(MyWebBrowser);
TWinControl(MyWebBrowser).Parent = PageControl1;
MyWebBrowser->Align = alClient;
MyWebBrowser->Visible = true;
MyWebBrowser->Navigate("[URL unfurl="true"]http://www.google.co.uk");[/URL]

Now I'm just deciding whether to stick with Borland/Codegear, or use MFC - I tend to prefer MS IDE's. There seems to be more code available for MFC too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top