动态创建的WebBrowser显示不出来。
同桌老王 2003-10-17 09:07:19 unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, OleCtrls, SHDocVw;
type
TMyWebBrowser = class(TWebBrowser)
public
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); dynamic;
end;
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
web2:TMyWebBrowser;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
web2:=TMyWebBrowser.CreateParented(Form1.Handle);
web2.Left:=100;
web2.Top:=12;
web2.Width:=300;
web2.Height:=300;
web2.Visible:=True;
web2.Align:= alClient;
web2.Show;
web2.Navigate('http://www.sina.com.cn');
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Application.MessageBox('sss','sss',0);
end;
procedure TMyWebBrowser.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowMessage('ok');
end;
end.