FireMonkey 使用Webbrowser
DELPHI XE5 源码PASCAL:http://files.cnblogs.com/xe2011/FireMonkey_Webbrowser.rar
为了这个用上webbrowser真是费太大劲了
要让窗体2位置和窗体1的PANEL坐标一致
但是fire monkey没有webbrowser控件 这个费了好长时间搞成这样了
现在还有个问题没有处理
1 unit Unit1; 2 3 interface 4 5 uses 6 Windows, Messages, FMX.Platform.Win, 7 System.SysUtils, System.Types, System.UITypes, System.Classes, 8 System.Variants, 9 FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, 10 FMX.Layouts, FMX.Memo; 11 12 type 13 TForm1 = class(TForm) 14 Button1: TButton; 15 Panel1: TPanel; 16 Button3: TButton; 17 Memo1: TMemo; 18 Timer1: TTimer; 19 Button4: TButton; 20 Button2: TButton; 21 procedure FormCreate(Sender: TObject); 22 procedure Button1Click(Sender: TObject); 23 24 procedure FormShow(Sender: TObject); 25 procedure FormMouseUp(Sender: TObject; Button: TMouseButton; 26 Shift: TShiftState; X, Y: Single); 27 procedure Button3MouseDown(Sender: TObject; Button: TMouseButton; 28 Shift: TShiftState; X, Y: Single); 29 procedure Timer1Timer(Sender: TObject); 30 procedure Button4Click(Sender: TObject); 31 procedure Button2Click(Sender: TObject); 32 private 33 { Private declarations } 34 procedure Form2RePosition; 35 public 36 37 end; 38 39 var 40 Form1: TForm1; 41 42 implementation 43 44 {$R *.fmx} 45 46 uses 47 UnitX; 48 49 var 50 Form2: TForm2; 51 52 procedure TForm1.FormCreate(Sender: TObject); 53 begin 54 Form2 := TForm2.Create(nil); 55 Form2.WebBrowser1.Navigate(‘http://w2i.wanmei.com/launcher/index.htm‘); 56 Form2.AutoSize := true; 57 Form2.Show; 58 end; 59 60 procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; 61 Shift: TShiftState; X, Y: Single); 62 begin 63 Form2RePosition; 64 65 end; 66 67 procedure TForm1.FormShow(Sender: TObject); 68 begin 69 Form2.Width := Round(Panel1.Width); 70 Form2.Height := Round(Panel1.Height); 71 Form2RePosition; 72 end; 73 74 procedure TForm1.Timer1Timer(Sender: TObject); 75 begin 76 Form2RePosition; 77 end; 78 79 procedure TForm1.Button2Click(Sender: TObject); 80 begin 81 Form2.Visible := not Form2.Visible; 82 83 end; 84 85 procedure TForm1.Button3MouseDown(Sender: TObject; Button: TMouseButton; 86 Shift: TShiftState; X, Y: Single); 87 begin 88 ReleaseCapture(); 89 SendMessage(FmxHandleToHwnd(Handle), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); 90 end; 91 92 procedure TForm1.Button4Click(Sender: TObject); 93 begin 94 WindowState := TWindowState.wsMinimized; 95 end; 96 97 procedure TForm1.Form2RePosition; 98 begin 99 if WindowState = TWindowState.wsNormal then 100 begin 101 Form2.Left := Round(Form1.Left + Panel1.Position.X); 102 Form2.Top := Round(Form1.Top + Panel1.Position.Y); 103 SetWindowPos(Form2.Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE + SWP_SHOWWINDOW); 104 end 105 else 106 Form2.Visible := false; 107 Form2.Visible:= (WindowState = TWindowState.wsNormal); 108 end; 109 110 procedure TForm1.Button1Click(Sender: TObject); 111 begin 112 close; 113 end; 114 115 end.
1 unit UnitX; 2 3 interface 4 5 uses 6 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 7 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw, Vcl.Imaging.jpeg, 8 Vcl.ExtCtrls; 9 10 type 11 TForm2 = class(TForm) 12 WebBrowser1: TWebBrowser; 13 Timer1: TTimer; 14 procedure FormCreate(Sender: TObject); 15 procedure FormShow(Sender: TObject); 16 private 17 { Private declarations } 18 public 19 { Public declarations } 20 end; 21 22 var 23 Form2: TForm2; 24 25 implementation 26 27 {$R *.dfm} 28 29 procedure TForm2.FormCreate(Sender: TObject); 30 begin 31 Width:=518; 32 Height:=221; 33 end; 34 35 procedure TForm2.FormShow(Sender: TObject); 36 begin 37 ShowWindow(Application.handle, SW_HIDE); 38 SetWindowLong(Self.handle, GWL_EXSTYLE, GetWindowLong(Self.handle, 39 GWL_EXSTYLE) ); // 不在alt+tab中出现 40 end; 41 42 end.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。