|
#1
|
|||
|
|||
PageControl
Помогите!!!Я хочу чтобы мой браузер открывал новые вкладки??как это зделать?
Код:
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, OleCtrls, SHDocVw, StdCtrls, Menus, sSkinManager, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP; type TForm2 = class(TForm) Panel1: TPanel; ProgressBar1: TProgressBar; Edit1: TEdit; Image1: TImage; Image2: TImage; Image3: TImage; Image4: TImage; Image5: TImage; MainMenu1: TMainMenu; N1: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; N8: TMenuItem; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; sSkinManager1: TsSkinManager; N2: TMenuItem; SaveDialog1: TSaveDialog; IdHTTP1: TIdHTTP; PageControl1: TPageControl; OpenDialog1: TOpenDialog; TabSheet1: TTabSheet; TabSheet2: TTabSheet; TabSheet3: TTabSheet; WebBrowser1: TWebBrowser; WebBrowser2: TWebBrowser; WebBrowser3: TWebBrowser; WebBrowser4: TWebBrowser; procedure N4Click(Sender: TObject); procedure Image1Click(Sender: TObject); procedure Image2Click(Sender: TObject); procedure Image4Click(Sender: TObject); procedure Image5Click(Sender: TObject); procedure Image3Click(Sender: TObject); procedure WebBrowser1NavigateComplete2(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant); procedure WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch; var Cancel: WordBool); procedure WebBrowser1ProgressChange(ASender: TObject; Progress, ProgressMax: Integer); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure N8Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N11Click(Sender: TObject); procedure PageControl1Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation uses Unit1, Unit3, Unit4, Unit5; {$R *.dfm} procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: Char); begin if key=char(13) then webbrowser1.Navigate(Edit1.Text); end; procedure TForm2.Image1Click(Sender: TObject); begin webbrowser1.goback; end; procedure TForm2.Image2Click(Sender: TObject); begin webbrowser1.goforward; end; procedure TForm2.Image3Click(Sender: TObject); begin webbrowser1.Navigate(Edit1.Text); end; procedure TForm2.Image4Click(Sender: TObject); begin webbrowser1.Refresh; end; procedure TForm2.Image5Click(Sender: TObject); begin webbrowser1.gohome; end; procedure TForm2.N10Click(Sender: TObject); begin Form4.Show; end; procedure TForm2.N11Click(Sender: TObject); begin Form5.Show; end; procedure TForm2.N4Click(Sender: TObject); begin Close; end; procedure TForm2.N6Click(Sender: TObject); begin Form3.Show; end; procedure TForm2.N8Click(Sender: TObject); begin Form1.Show; end; procedure TForm2.PageControl1Change(Sender: TObject); var web:TWebBrowser; tab: TTabSheet; begin tab := TTabSheet.Create(PageControl); tab.PageControl := PageControl; tab.Visible := true; PageControl.ActivePage := tab; tab.Align:= alClient; web := TWebBrowser.Create(tab); web.Parent := tab; web.Align:= alClient; web.Visible := true; end; procedure TForm2.WebBrowser1NavigateComplete2(ASender: TObject; const pDisp: IDispatch; var URL: OleVariant); begin Edit1.Text:=URL; end; procedure TForm2.WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch; var Cancel: WordBool); var newform:Tform2; begin ppdisp:=webbrowser1.Defaultdispatch; newform:=tform2.Create(self); newform.show; ppdisp:=newform.WebBrowser1.DefaultDispatch; end; procedure TForm2.WebBrowser1ProgressChange(ASender: TObject; Progress, ProgressMax: Integer); begin Progressbar1.max:=ProgressMax; Progressbar1.Position:=Progress; end; end. |