FireMonkey 使用Webbrowser

时间:2024-08-11 23:06:38

DELPHI XE5 源码PASCAL:http://files.cnblogs.com/xe2011/FireMonkey_Webbrowser.rar

FireMonkey 使用Webbrowser

为了这个用上webbrowser真是费太大劲了

FireMonkey 使用Webbrowser

要让窗体2位置和窗体1的PANEL坐标一致

窗体样式要为none 
Web坐标才会正确

但是fire monkey没有webbrowser控件 这个费了好长时间搞成这样了

FireMonkey 使用Webbrowser

现在还有个问题没有处理

FireMonkey 使用Webbrowser

 unit Unit1;

 interface

 uses
Windows, Messages, FMX.Platform.Win,
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FMX.Layouts, FMX.Memo; type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Button3: TButton;
Memo1: TMemo;
Timer1: TTimer;
Button4: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject); procedure FormShow(Sender: TObject);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure Button3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure Timer1Timer(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure Form2RePosition;
public end; var
Form1: TForm1; implementation {$R *.fmx} uses
UnitX; var
Form2: TForm2; procedure TForm1.FormCreate(Sender: TObject);
begin
Form2 := TForm2.Create(nil);
Form2.WebBrowser1.Navigate('http://w2i.wanmei.com/launcher/index.htm');
Form2.AutoSize := true;
Form2.Show;
end; procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
Form2RePosition; end; procedure TForm1.FormShow(Sender: TObject);
begin
Form2.Width := Round(Panel1.Width);
Form2.Height := Round(Panel1.Height);
Form2RePosition;
end; procedure TForm1.Timer1Timer(Sender: TObject);
begin
Form2RePosition;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
Form2.Visible := not Form2.Visible; end; procedure TForm1.Button3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
ReleaseCapture();
SendMessage(FmxHandleToHwnd(Handle), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, );
end; procedure TForm1.Button4Click(Sender: TObject);
begin
WindowState := TWindowState.wsMinimized;
end; procedure TForm1.Form2RePosition;
begin
if WindowState = TWindowState.wsNormal then
begin
Form2.Left := Round(Form1.Left + Panel1.Position.X);
Form2.Top := Round(Form1.Top + Panel1.Position.Y);
SetWindowPos(Form2.Handle, HWND_TOP, , , , , SWP_NOSIZE + SWP_NOMOVE + SWP_SHOWWINDOW);
end
else
Form2.Visible := false;
Form2.Visible:= (WindowState = TWindowState.wsNormal);
end; procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end; end.

FMX unit1

 unit UnitX;

 interface

 uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw, Vcl.Imaging.jpeg,
Vcl.ExtCtrls; type
TForm2 = class(TForm)
WebBrowser1: TWebBrowser;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form2: TForm2; implementation {$R *.dfm} procedure TForm2.FormCreate(Sender: TObject);
begin
Width:=;
Height:=;
end; procedure TForm2.FormShow(Sender: TObject);
begin
ShowWindow(Application.handle, SW_HIDE);
SetWindowLong(Self.handle, GWL_EXSTYLE, GetWindowLong(Self.handle,
GWL_EXSTYLE) ); // 不在alt+tab中出现
end; end.

VCL unit