Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi New TabSheet with TWebbrowser and TToolBar (https://www.delphipraxis.net/60340-new-tabsheet-twebbrowser-ttoolbar.html)

alpha1 5. Jan 2006 14:35


New TabSheet with TWebbrowser and TToolBar
 
Hello, how can i make, that on the new opened TabSheet would be TWebbrowser and TToolBar(with all Buttons, ...)? Here is my code but with error:

Delphi-Quellcode:
procedure TForm1.NewTab;
var Tab: TTabSheet;
    Browser: TWebBrowser;
begin
 Tab:= TTabSheet.Create(PageControl1);
 Tab.PageControl := PageControl1;
 Tab.Parent := PageControl1;
 Tab.PageIndex := PageControl1.ActivePageIndex + 1;
 ToolBar2.Create(Tab);
 TControl(ToolBar2).Parent := Tab;
 ToolBar2.Align := alTop;
 Browser:= TWebBrowser.Create(Tab);
 TControl(Browser).Parent := Tab;
 Browser.Align := alClient;
 Browser.Silent := True;
 Browser.Visible := True;
 PageControl1.ActivePage := Tab;
 Browser.OnStatusTextChange := WebBrowser1StatusTextChange;
 Browser.OnTitleChange := WebBrowser1TitleChange;
 Browser.OnNewWindow2 := WebBrowser1NewWindow2;
 Browser.OnCommandStateChange := WebBrowser1CommandStateChange;
 ImageButton1.Enabled := False;
 ImageButton2.Enabled := False;
 Browser.Navigate('about:blank');
end;
This code opens new TabSheet with TWebbrowser and TToolBar but with error. Also in previous TabSheet this TToolBar lost...
Please help me :roll:

jim_raynor 5. Jan 2006 14:37

Re: New TabSheet with TWebbrowser and TToolBar
 
Here is an error:

Delphi-Quellcode:
ToolBar2.Create(Tab);
correct it must be:

Delphi-Quellcode:
ToolBar2:=TToolBar.Create(Tab);

marabu 5. Jan 2006 15:06

Re: New TabSheet with TWebbrowser and TToolBar
 
While ToolBar2.Create() effectively reinitializes the ToolBar you already employ on your first tabsheet, ToolBar2 := TToolBar.Create() overwrites the global variable ToolBar2 you might use elsewhere to refer to the prevous instance. Think twice - normally only one toolbar is assigned to a form with a pagecontrol. Position is preferably on top of the form, right below the menu. If the user changes the active tabsheet, you query the state of the command buttons from the then active browser control.

marabu


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz