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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, this is my first topic/post her

Status
Not open for further replies.

Shedfire

Programmer
Sep 11, 2003
4
NL
Hi, this is my first topic/post here, so please be gentle :)
For the last 3 days I have this problem with Delphi 7's TWebBrowser Component.
I would like to build this:
A form with a TButton and a TPageControl.
When I press the button a new page (TTabSheet) is created in the PageControl1. And in the new page there has to be a TWebBrowser Component with its Align := alClient.

Well everything goes A-Ok until this: "with its Align := alClient".
I do not get a error but the WebBrowser isn't as big as it should be (only 100 by 20 pixels). It also doesn't respond on the fullscreen, width and height properties.

This is my code:
Code:
procedure TForm1.createPage();
var t : TTabSheet;
begin
        PageControl1.Align := alClient;
        t := TTabSheet.Create(PageControl1);
        with t do
        begin
                PageControl := PageControl1;
                Name := 'TabSheet' + IntToStr(pageN);
                Caption := 'Page' + IntToStr(pageN);
                Align := alClient;

                with TWebBrowser.Create(t) do
                begin
                       Align := alClient; //doesn't work
                       Navigate ('[URL unfurl="true"]http://www.yahoo.com');[/URL] //does work
                       ParentWindow := t.Handle;
                end;
        end;
        pageN := pageN + 1; //pageN is a Integer
end;

I really hope someone can help me with this.
Greets Sjoerd
 
I forgot to put a topic title
"TWebBrowser Alignment in a TTabsheet"
Is there a way to edit a post?
 
with:

with TWebBrowser.Create(t) do
begin
Align := alClient; //doesn't work
Navigate (' //does work
ParentWindow := t.Handle;
end;

you might want to try:

with TWebBrowser.Create(t) do
begin
Parent := t;
Align := alClient; //doesn't work
Navigate (' //does work
// ParentWindow := t.Handle; //dont think you need this
end;

when you dynamically create visual controls, you need to set their parent to the owner (as passed in during the create(AOwner: TComponent).

hope that helps
 
Parent is a readonly property.
So you can't set it.
 
hi,

I changed your code a bit and it is now working.

procedure TForm1.createPage();
var t : TTabSheet;
w : TWebBrowser;
p : TPanel;
begin
t := TTabSheet.Create(PageControl1);
with t do
begin
PageControl := PageControl1;
Name := 'TabSheet' + IntToStr(pageN);
Caption := 'Page' + IntToStr(pageN);
p := TPanel.Create(t);
p.Caption := '';
p.Align := alClient;
t.InsertControl(p);
end;
pageN := pageN + 1; //pageN is a Integer

w := TWebBrowser.Create(p);
w.Align := alClient; //doesn't work
p.InsertControl(w);
w.Navigate(' //does work
end;


I added a Panel on every tab and used insertcontrol to set the parent

Hope this answers your problem

Steph [Bigglasses]
 
Wow thank you very much!
It works :)
May I ask how you got this answer? (experience, or a website/book?)

Greeting from Sjoerd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top