Это описано в следующей статье Питера Джонсона, How to make a TWebBrowser become the active control when clicked.
Резюмируя сильно, добавьте 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;
Существует много более подробно в статье, пожалуйста, убедитесь, что вы прочитали все это.
В SO лучше всего задавать вопросы отдельно. Суть SO заключается в создании хранилища вопросов с высококачественными ответами. Если вы получите два отдельных ответа на свои вопросы, которые вы примете? – Argalatyr
Делает смысл. Я буду создавать отдельные вопросы в будущем. Джейсон. – 2009-05-28 05:57:50