HtmlViewer 11.x (recommended) - is a full WideString version suitable for projects with most common codepages/charsets. - with Delphi 6..2007 requires the TntUnicodeControls. - works with Delphi 6 or newer (recommended at least 2009) - works with Lazarus 0.9.30 or newer (recommended at least 1.2.x) for Windows, Linux and Raspbian - 32 and 64 BitOpenURL是最简单的一个方法,通过一个方法检查默认浏览器,然后通过传递参数来打开它。在窗体中可以是'mailto:aname@anaddress?subject=:::a subject',或者是一个网站地址"http://"或者"https://"
uses LCLIntf; ... OpenURL('http://www.lazarus.freepascal.org');查找默认浏览器
在每个平台上面都有它不同的默认浏览器,在LCL unit lazhelphtml中保函了一个THTMLBrowserHelpViewer来启动一个浏览器来查看LCL帮助系统。你可以使用他的FindDefaultBrowser方法来查找默认浏览器,然后传递参数来启动他,例如:
uses Classes, ..., LCLProc, LazHelpHTML; ... implementation procedure TMainForm.Button1Click(Sender: TObject); var v: THTMLBrowserHelpViewer; BrowserPath, BrowserParams: string; begin v:=THTMLBrowserHelpViewer.Create(nil); v.FindDefaultBrowser(BrowserPath,BrowserParams); debugln(['Path=',BrowserPath,' Params=',BrowserParams]); v.Free; end;
给出的例子,在 Linux中:
Browser=/usr/bin/xdg-open Params=%s
在Windows中你可以获取:
Browser=C:\windows\system32\rundll32.exe Params=url.dll,FileProtocolHandler %s
打开一个浏览器
你可以使用TProcessUTF8通过命令行来启动一个浏览器:
uses Classes, ..., LCLProc, LazHelpHTML, UTF8Process; ... implementation procedure TMainForm.Button1Click(Sender: TObject); var v: THTMLBrowserHelpViewer; BrowserPath, BrowserParams: string; p: LongInt; URL: String; BrowserProcess: TProcessUTF8; begin v:=THTMLBrowserHelpViewer.Create(nil); try v.FindDefaultBrowser(BrowserPath,BrowserParams); debugln(['Path=',BrowserPath,' Params=',BrowserParams]); URL:='http://www.lazarus.freepascal.org'; p:=System.Pos('%s', BrowserParams); System.Delete(BrowserParams,p,2); System.Insert(URL,BrowserParams,p); // start browser BrowserProcess:=TProcessUTF8.Create(nil); try BrowserProcess.CommandLine:=BrowserPath+' '+BrowserParams; BrowserProcess.Execute; finally BrowserProcess.Free; end; finally v.Free; end; end;
内嵌浏览器组件到程序
使用Turbopower互联网控件
lazarus提供一个TurboPowerIPro包(lazarus/components/turbopower_ipro/turbopoweripro.lpk)保函下面功能:- It contains a control to put onto a form. When you install the package in the IDE, you get some new components in the palette, so you can drop them onto a form just like any LCL control.
- It is written completely in Pascal and therefore works on all platforms out of the box without any extra installation.
- You have the full control, what files/urls are opened.
- It does not have all the features of a full webbrowser. No multimedia stuff, javascript or flash. This must be implemented by you.