两个快速问题
有什么想法吗?
谢谢杰森。
发布于 2009-05-28 01:55:38
在大量的网络搜索之后,回答问题1.
with WebBrowser1 do
if Document <> nil then
with Application as IOleobject do
DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect);发布于 2014-10-09 14:02:04
这将在Peter,如何使TWebBrowser在单击时成为活动控件的下一篇文章中介绍。
要进行大量总结,请添加以下OnCommandStateChange事件:
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;这篇文章中有更多的细节,请务必全部阅读。
https://stackoverflow.com/questions/918816
复制相似问题