以前的笔记或摘录:在TEmbeddedWB中使用自己的右键菜单

 uses
  MSHTML;

function TForm1.WebBrowser1ShowContextMenu(const dwID: Cardinal;
  const ppt: PPoint; const pcmdtReserved: IInterface;
  const pdispReserved: IDispatch): HRESULT;
var
  myHTMLWindow2: IHTMLWindow2;
  oHTMLEvent: IHTMLEventObj;
  oHTMLDoc2: IHTMLDocument2;
begin
  //next block gives access to the event object fired when the user
  //right-clicks inside the webBrowser control
  oHTMLDoc2 := EmbeddedWB1.Document as IHTMLDocument2; //interface to the displayed doc
  myHTMLWindow2 := oHTMLDoc2.parentWindow;
  //interface to the window that handles the events
  oHTMLEvent := myHTMLWindow2.event; //HERE is the event object
  if oHTMLEvent.ctrlKey = system.False then
  begin //if the Ctrl key is NOT pressed during right-click..
    oHTMLEvent.returnValue := False; //...kills the default pop-up of IE
    Result := 0;
    //open my PopUp nemu at the absolute X and Y coordinates of the mouse
    PopupMenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  EmbeddedWB1.Navigate('www.swissdelphicenter.com');
end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TEmbeddedWB是一个很好的IE编程控件,现支持Delphi2009! =================================== Version 14.66.1 =================================== This version adds some constants for IE8, D2009 compatibility and includes some fixes / changes. * file EWB.inc: Added D2007, D2009 defines. {$IFDEF DELPHI_13_UP} {$ELSE} {$ENDIF} * EWBCore.pas: EnableThemes is set to True by default (I think this makes sense) -> UserInterfaceOptions := [EnableThemes]; * unit TEmbeddedWB.pas - Removed the Wait() in TEmbeddedWB.GetFrame as it could block - Modified Visible Property to work properly. Instead of TControl(TEmbeddedWB).Visible you can write TEmbeddedWB.Visible - Bsalsa UserAgent is not automatically set anytime anymore as it causes some problems. -> Modified SetUserAgent. Renamed RemoveUserAgent to RestoreUserAgent - Fix: Handle M_GETDLGCODE message in TEmbeddedWB.WndProc * unit IEConst: - Added constants that are missing in previous delphi versions: BINDSTATUS_COOKIE_SENT = BINDSTATUS_ACCEPTRANGES + 1; BINDSTATUS_COMPACT_POLICY_RECEIVED = BINDSTATUS_COOKIE_SENT + 1; BINDSTATUS_COOKIE_SUPPRESSED = BINDSTATUS_COMPACT_POLICY_RECEIVED + 1; BINDSTATUS_COOKIE_STATE_UNKNOWN = BINDSTATUS_COOKIE_SUPPRESSED + 1; BINDSTATUS_COOKIE_STATE_ACCEPT = BINDSTATUS_COOKIE_STATE_UNKNOWN + 1; BINDSTATUS_COOKIE_STATE_REJECT = BINDSTATUS_COOKIE_STATE_ACCEPT + 1; BINDSTATUS_COOKIE_STATE_PROMPT = BINDSTATUS_COOKIE_STATE_REJECT + 1; BINDSTATUS_COOKIE_STATE_LEASH = BINDSTATUS_COOKIE_STATE_PROMPT + 1; BINDSTATUS_COOKIE_STATE_DOWNGRADE = BINDSTATUS_COOKIE_STATE_LEASH + 1; BINDSTATUS_POLICY_HREF = BINDSTATUS_COOKIE_STATE_DOWNGRADE + 1; BINDSTATUS_P3P_HEADER = BINDSTATUS_POLICY_HREF + 1; BINDSTATUS_SESSION_COOKIE_RECEIVED = BINDSTATUS_P3P_HEADER + 1; BINDSTATUS_PERSISTENT_COOKIE_RECEIVED = BINDSTATUS_SESSION_COOKIE_RECEIVED + 1; - Added IE8 constants: BINDSTATUS_COOKIE_DATA = BINDSTATUS_SSLUX_NAVBLOCKED + 1; //IE8 BINDSTATUS_SERVER_MIMETYPEAVAILABLE = BINDSTATUS_COOKIE_DATA + 1; //IE8 BINDSTATUS_SNIFFED_CLASSIDAVAILABLE = BINDSTATUS_SERVER_MIMETYPEAVAILABLE + 1; //IE8 BINDSTATUS_64BIT_PROGRESS = BINDSTATUS_SNIFFED_CLASSIDAVAILABLE + 1; //IE8 * unit IEDownloadTools: - Added the new IE8 results to the function BindStatusText: BINDSTATUS_COOKIE_DATA: Result := 'Cookie headers have been received'; //IE8 - Attention: This documentation is preliminary and is subject to chang BINDSTATUS_SERVER_MIMETYPEAVAILABLE: Result := 'Server''s authoritative MIME type reported'; //IE8 - Attention: This documentation is preliminary and is subject to chang BINDSTATUS_SNIFFED_CLASSIDAVAILABLE: Result := 'Class identifier (CLSID) generated from authoritative Content-Type HTTP response header'; //IE8 - Attention: This documentation is preliminary and is subject to chang BINDSTATUS_64BIT_PROGRESS: Result := 'Download progress values are above the maximum 32-bit file size limit.'; //IE8 - Attention: This documentation is preliminary and is subject to chang * Various changes to make it D2009 compatible
Delphi第三方控件EmbeddedWB,这是一个不错的浏览器控件,比Delphi自带的Webbrowser要强悍 EmbeddedWB安装方法: 1.下载压缩包,飘易下载的是EmbeddedWB v14.67.0版本,下载地址:http://www.delphifans.com/SoftView/SoftView_2705.html。 2.解压整个压缩包到 lib\EmbeddedWB 下; 3.复制 lib\EmbeddedWB 下的Packages目录EmbeddedWebBrowser_D2007.dpk(因为飘易使用的是DELPHI2007)到Source目录里; 4.用Delphi7开发环境打开 EmbeddedWebBrowser_D2007.dpk 文件,按Optios按钮,作如下调整: Directories/Conditionals标签Unit Output Dir=“D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source”(具体路径自行决定); 5.按Compile 再按Install; 6.不要保存变化了的dpk文件及压缩包; 7.在具体的编译工程时,需检查该源目录(D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source)在 Delphi IDE 的 "Search Path" 路径里(Project -> Options -> irectories/Conditionals -> Search Path); 如果没有,添加这个源目录路径。否则,在使用该控件的时候,出现“File not found: 'SHDocVw_EWB.dcu'” 错误。 8.可以正常使用了。 这里还有一篇别人的“Embedded Web Browser Delphi组件的安装”,不过是把TEmbeddedWB控件安装到 Delphi7 里的。 下面是D2005 installing steps:1.After downloading Unzip the package. 2. Put the folder that contain the package in the path "..:\Borland\BDS\3.0\lib" 3. Open Delphi IDE and press in the menu bar On: File --> "Open" In the open dialog navigate to the path where you store your package to the source folder("..:\Borland\BDS\3.0\lib\EmbeddedWB_D2005\Source"). 5.Choose file name "EmbeddedWebBrowser_D2005.dpk" and press open. 6.In the project manager (in the right corner) point with your mouse on the top file ("EmbeddedWebBrowser_D2005.bdsproj"). Then Right click and choose "Build" 7. And last In the same file & menu Press install. 8. Do not save the package changes. 9. You should make sure that the source folder is in the Delphi IDE "Search Path". If not You must add it.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值