首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >德尔福- TWebBrowser问题

德尔福- TWebBrowser问题
EN

Stack Overflow用户
提问于 2009-05-28 01:37:59
回答 2查看 2.3K关注 0票数 3

两个快速问题

  1. 如何将焦点设置为TWebBrowser?这样鼠标轮就可以滚动显示,而不必先在TWebBrwoser显示区域内单击。它有一个setfocus方法,它什么也不做(或者似乎什么也不做)。
  2. 在TWebBrowser中,右键单击显示的链接并选择属性。“确定”和“取消”按钮被禁用,您无法关闭对话框。你需要结束你的应用程序的任务来杀死它。

有什么想法吗?

谢谢杰森。

EN

回答 2

Stack Overflow用户

发布于 2009-05-28 01:55:38

在大量的网络搜索之后,回答问题1.

代码语言:javascript
复制
 with WebBrowser1 do
 if Document <> nil then
 with Application as IOleobject do
 DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect);
票数 6
EN

Stack Overflow用户

发布于 2014-10-09 14:02:04

这将在Peter,如何使TWebBrowser在单击时成为活动控件的下一篇文章中介绍。

要进行大量总结,请添加以下OnCommandStateChange事件:

代码语言:javascript
复制
procedure TWebBrowserFrame.CommandStateChange(Sender: TObject;
  Command: Integer; Enable: WordBool);
var
  Doc: IHTMLDocument2;        // document object
  Sel: IHTMLSelectionObject;  // current selection
begin
  // Check we have a valid web browser triggering this event
  if not Assigned(Sender) or not (Sender is TWebBrowser) then
    Exit;
  // Check we have required command
  if TOleEnum(Command) <> CSC_UPDATECOMMANDS then
    Exit;
  // Get ref to document object and check not nil
  Doc := Browser.Document as IHTMLDocument2;
  if not Assigned(Doc) then
    Exit;
  // Get ref to current selection
  Sel := Doc.selection as IHTMLSelectionObject;
  // If selection is of correct type then we have a mouse click
  if Assigned(Sel) and (Sel.type_ = 'Text') then
  begin
    // Make the web browser the form's active control
    (Sender as TWebBrowser).SetFocus;
    Doc.parentWindow.focus;
  end;
end;

这篇文章中有更多的细节,请务必全部阅读。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/918816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档