Recent

Author Topic: Show website in a form  (Read 11696 times)

Kips

  • New Member
  • *
  • Posts: 27
Show website in a form
« on: August 24, 2011, 11:19:13 am »
hi,


I want to show a website in a form. I am working with Lazarus for windows.

The following code creates an Internet Explorer object, and place it on a form. The object is descripted here: http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx

My problem is that the Internet Explorer scrollbars, captions and buttons is visible.

The only way to fix that is to set FullScreen to True but then the object can't be resized  :(

I want to make the buttons and stuff disappear AND make the object resizeable - any ideas?!

Should I use the WebBrowser Object instead:
http://msdn.microsoft.com/en-us/library/aa752085%28v=VS.85%29.aspx#3


unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  Comobj, windows;

type

  { TForm1 }

  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { private declarations }
    browser: olevariant;
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var

  s:variant;

begin
  panel1.align:=alClient;
  browser := CreateOleObject('InternetExplorer.Application');
  windows.setparent(browser.hwnd, panel1.handle);
  browser.toolbar:=true;
  browser.fullscreen:=false;   //browser.fullscreen:=true;
  browser.Resizable:=true;
  browser.visible:=true;


  s:='http://www.microsoft.com';
  Browser.Navigate(s);

end;

procedure TForm1.FormResize(Sender: TObject);
begin
  browser.width:=clientWidth;
  browser.height:=clientHeight;

end;

end.
« Last Edit: August 24, 2011, 01:02:20 pm by Kips »

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: Show website in a form
« Reply #1 on: December 21, 2011, 03:52:08 pm »
I tried but it isn't worked correctly also i tried more sample of OLE but i am not successful.

In delphi you can show web site with by a activex but lazarus is a cross platform compiler and don't support this method yet.


zzsczz

  • Newbie
  • Posts: 5
Re: Show website in a form
« Reply #2 on: December 21, 2011, 04:28:10 pm »
fpc : fixes_2_6      r19871
lazarus : fixes_0_9_30 r34261
win32  (win7 os  64bit)

Kips' code works well
 see attach
fpc : fixes_2_6      r19871
lazarus : fixes_0_9_30 r34261

joseme

  • Full Member
  • ***
  • Posts: 128
    • Logosoft sistemas
Re: Show website in a form
« Reply #3 on: December 21, 2011, 05:18:45 pm »
I am testing the Gecko port and it works very well. The browser does not show scrollbars or buttons, and its resizeable  :)
un aporte a la comunidad:
http://pascalylazarus.blogspot.com/

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Show website in a form
« Reply #4 on: December 21, 2011, 07:19:26 pm »
The Gecko port works fine but has a few disadvantages. The binding is at level 1.9 while the latest xulrunner is 8.0. The learning curve is also quite steep and it takes a lot to get your first app running.
You can also use the 'Shell.Explorer' ActiveX object. See http://lazarus.freepascal.org/index.php/topic,9311.15/topicseen.html? Drop a panel on the form, run the code and the ActiveX control will be displayed on the panel. The browser will re-size with the panel.
The original demo at http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-May/063491.html shows also how to sink events coming from the ActiveX control.

bambamns

  • Full Member
  • ***
  • Posts: 223
Re: Show website in a form
« Reply #5 on: May 11, 2012, 06:01:24 am »
Try this - it's working now like TWebBroser in Delphi.
http://wiki.freepascal.org/LazActiveX
Lazarus 1.8.4 + FPC 2.6.4 x86 (rebuild) and Lazarus 2.0, Windows 7 x64, unless otherwise specified

 

TinyPortal © 2005-2018