Home > Back-end >  Code error, please advise thanks!
Code error, please advise thanks!

Time:10-21

The unit Unit1;


Interface


USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl. OleCtrls, SHDocVw, Vcl. StdCtrls;


Type
TForm1=class (TForm)
Edit1: TEdit;
For: TButton;
WebBrowser1: TWebBrowser;
WebBrowser2: TWebBrowser;
Procedure Button1Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;


Var
Form1: TForm1;
PpDisp: IDispatch;
Cancel: WordBool




Implementation


{$R *. DFM}


Procedure TForm1. Button1Click (Sender: TObject);
The begin
WebBrowser1. Navigate (Edit1. Text);
end;
Procedure TForm1. WebBrowser1NewWindow2 (ASender: TObject; Var ppDisp: IDispatch; Var Cancel: WordBool);
The begin
PpDisp:=WebBrowser2. Application;
end;


Procedure TForm1. WebBrowser2BeforeNavigate2 (ASender: TObject; Const pDisp: IDispatch; Var URL, Flags, TargetFrameName PostData, Headers: OleVariant; Var Cancel: WordBool);
The begin
WebBrowser1. Navigate (URL);
Cancel:=True;
end;
End.



CodePudding user response:

1, Cancel the variables defines the missing semicolon;
2, WebBrowser1NewWindow2 and less WebBrowser2BeforeNavigate2 event definition;

CodePudding user response:

Thank you very much! Any definition excuse me? I'm a little white,,,

CodePudding user response:

It's convenient to write code? Thank you!

CodePudding user response:

 
The unit Unit1;


Interface


USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl. OleCtrls, SHDocVw, Vcl. StdCtrls;


Type
TForm1=class (TForm)
Edit1: TEdit;
For: TButton;
WebBrowser1: TWebBrowser;
WebBrowser2: TWebBrowser;
Procedure Button1Click (Sender: TObject);
Procedure WebBrowser1NewWindow2 (ASender: TObject; Var ppDisp: IDispatch; Var Cancel: WordBool);
Procedure WebBrowser2BeforeNavigate2 (ASender: TObject; Const pDisp: IDispatch; Var URL, Flags, TargetFrameName PostData, Headers: OleVariant; Var Cancel: WordBool);
Private
{Private declarations}
Public
{Public declarations}
end;


Var
Form1: TForm1;
PpDisp: IDispatch;
Cancel: WordBool;




Implementation


{$R *. DFM}


Procedure TForm1. Button1Click (Sender: TObject);
The begin
WebBrowser1. Navigate (Edit1. Text);
end;

Procedure TForm1. WebBrowser1NewWindow2 (ASender: TObject; Var ppDisp: IDispatch; Var Cancel: WordBool);
The begin
PpDisp:=WebBrowser2. Application;
end;


Procedure TForm1. WebBrowser2BeforeNavigate2 (ASender: TObject; Const pDisp: IDispatch; Var URL, Flags, TargetFrameName PostData, Headers: OleVariant; Var Cancel: WordBool);
The begin
WebBrowser1. Navigate (URL);
Cancel:=True;
end;
End.


Behind the two events, you had better be in control of the corresponding double-click to create out of the event is better,

CodePudding user response:

Thank you for your great apes

CodePudding user response:

DELPHI 7
According to
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,

File not found Winapi. Windows. Dcu

CodePudding user response:

USES the

Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl. OleCtrls, SHDocVw, Vcl. StdCtrls;

Make a mistake,,,

CodePudding user response:

This is not D7 code,
Try:

 
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, OleCtrls SHDocVw, StdCtrls;

CodePudding user response:

Good
Now run after WebBrowser1 web content was blocked by WebBrowser2 then narrowed WebBrowser2 see WebBrowser1 web content however, click the link inside have no reaction,,,