Forum > Networking and Web Programming

Webbrowser demo (Windows)

(1/3) > >>

Timewarp:
Created small tabbed webbrowser for Windows. It's based on IE / activexcontainer.pas

Screencap: http://i.imgur.com/RYRlb.jpg

Download: http://netikka.net/dev/LazBrowserDemo.zip
(could not attach, because of size)

Demo shows (for example) how to:

- Create tabbed browser
- Keyboard hook to capture key presses
- Mouse hook to capture mouse events
- Addressbar autocomplete (shlwapi)
- Read/write typed urls to registry
- Don't show Javascript errors
- Make tab key, F5, zooming work..
- Run webbrowsercontrol in IE8/9/10 mode
- Disable navigation sounds
- Disable activex / javascript / change other downloadoptions
- Disable scripts from specific domain/url(s)
- Redirect xxx to yyy using Translateurl
- Clear IE cache
- Use own useragent
- ...

It's cut from my larger Delphi project, not sure if I removed all useless code?!   

You can do whatever you like with it..

FPC 2.6.1 or later is needed. I have tested only latest 2.7.1. (for 64bit Lazarus FPC 2.7.1 compiled with -dTEST_WIN64_SEH is needed)

Timewarp:
Demo should work Lazarus 1.0.10 win32 (64bit Lazarus needs FPC2.7.1)

dcminus:
Hi TimeWarp,

great example, worked great for my project. Thanks for publishing it. I started to rewrite my delphi app and got stuck here:

I need to get the current source from the WebBrowser which I did like this:

--- Code: ---procedure TForm1.WBDocumentComplete(ASender: TObject; pDisp: IDispatch; var URL: OleVariant);
var r: integer;
 s: string;
 WB: TEvsWebBrowser;
 source: string;
iall: IHTMLElement;
begin
 WB:=TEvsWebBrowser(Asender);
 
  if Pos('analysis/analysis_main.asp',URL) > 0 then
    with WB.ComServer do
      begin
      if Assigned(document) then
      begin
         iall := (document AS IHTMLDocument2).Body;

         while iall.parentElement <> nil do
         begin
            iall := iall.parentElement;
         end;
         source := iall.outterHTML;
      end;
       FormDebug.Memo.Lines.Text:=source;
      ShowMessage('Done');
      end;

--- End code ---

The source I get is not the one belongs to "analysis_main.asp" but the parent html of that.

Could you be so kind and tell me what did I do wrong?

Thanks in advance,

DC

theo:
typo?: iall.outterHTML -> iall.outerHTML;

And don't use the "with" keyword, at least when debugging, it is confusing.

Timewarp:
What is the url?

Documentcomplete can fire many times (if there are frames for example) You most likely want to keep this line anyway.

if (pDisp as IWebBrowser)<>WB.comserver then exit;

Just one thing I discovered recently. It's better to set browser emulation registry key in initialization section. This way it affects immediately, not just after next run.

Navigation

[0] Message Index

[#] Next page

Go to full version