FireMonkey 使用Webbrowser

來源:互聯網
上載者:User

標籤:style   blog   class   code   tar   ext   

 

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

 

為了這個用上webbrowser真是費太大勁了

要讓表單2位置和表單1的PANEL座標一致

表單樣式要為none Web座標才會正確

 

但是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 then100     begin101       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     end105   else106       Form2.Visible := false;107       Form2.Visible:= (WindowState = TWindowState.wsNormal);108 end;109 110 procedure TForm1.Button1Click(Sender: TObject);111 begin112   close;113 end;114 115 end.
FMX unit1

 

 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 type11   TForm2 = class(TForm)12     WebBrowser1: TWebBrowser;13     Timer1: TTimer;14     procedure FormCreate(Sender: TObject);15     procedure FormShow(Sender: TObject);16   private17     { Private declarations }18   public19     { Public declarations }20   end;21 22 var23   Form2: TForm2;24 25 implementation26 27 {$R *.dfm}28 29 procedure TForm2.FormCreate(Sender: TObject);30 begin31     Width:=518;32     Height:=221;33 end;34 35 procedure TForm2.FormShow(Sender: TObject);36 begin37   ShowWindow(Application.handle, SW_HIDE);38   SetWindowLong(Self.handle, GWL_EXSTYLE, GetWindowLong(Self.handle,39     GWL_EXSTYLE) ); // 不在alt+tab中出現40 end;41 42 end.
VCL unit

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.