Not quite, but...
Do this:
Re-import the mshtml type library via Project/Import Type Library... (Make sure
to tick the "Generate Component Wrapper" checkbox at the bottom).
Then use this code (I called the imported mshtml Type Library mshtml60):
{$WARN SYMBOL_PLATFORM OFF}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, Dialogs, mshtml, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FGroupsAnchor: THTMLAnchorElement;
procedure GroupsAnchorClick(Sender: TObject);
public
end;
var
Form1: TForm1;
implementation
uses Mshtml60;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
FGroupsAnchor := THTMLAnchorElement.Create(nil);
FGroupsAnchor.Ononclick := GroupsAnchorClick;
WebBrowser1.Navigate('http://www.google.com');
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
var
Doc: IHTMLDocument2;
Disp: IDispatch;
Anchor: DispHTMLAnchorElement;
begin
if Supports(WebBrowser1.Document, IHTMLDocument2, Doc)
then begin
Disp := Doc.all.item('2a', 0); // 2a = id of the group link
if Supports(Disp, DispHTMLAnchorElement, Anchor)
then FGroupsAnchor.ConnectTo(Anchor);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FGroupsAnchor.Free;
end;
procedure TForm1.GroupsAnchorClick(Sender: TObject);
begin
ShowMessage('Clicked on Groups!');
end;
end.
--
Martin
var
fpe: TFrontPageEditorHTMLElementEvents;
Elements := fp.ActivePageWindow.Document.all.tags('Select') AS
IHTMLElementCollection;
Fe:= TFrontPageEditorHTMLElementEvents.Create(Self);
fe.Connect(fp.Get_ActiveDocument.Get_activeElement);//gives an error that
unable to connect - OLE errror blah blah blah
//fe.onclick:=ButtonInsertClick (gives an error of type mismatch);
Wadood
"Martin Kammann" <mNOka...@intellienceSPAM.comPLEASE> wrote in message
news:3c844e39_2@dnews...
I believe that feature is only available as with Delphi 5 and later.
> Using Binh Ly (http://www.techvanguards.com), I've generated two other files
> frontPage_editorEvent and mshml_Events, which have lot of Componentss with
> enticing names.
If you are talking about the EventSinkImp utility: that should do the job as
well. The steps to hook into the events are essentially the same as with the
D5&D6 version. It should do the job.
> TFrontPageEditorAnchorEvents, TFrontPageEditorImageEvents,
> TFrontPageEditorElementEvents, and so on - but I can not get it to connect
> to a source or assign it to my event handlers.
Sorry, I don't know about Frontpage automation. I was under the impression that
you were automating Internet Explorer or TWebBrowser.
--
Martin
Thanks very much.
Wadood
"Martin Kammann" <mNOka...@intellienceSPAM.comPLEASE> wrote in message
news:3c847ec7_1@dnews...
declaration of the connect method:
procedure Connect (const ASource: IUnknown);
ASource will be the HTML Element for which you want to trap the event.
You will need to locate the relevant HTML Element within the Document as
described in my reply to your initial post.
--
Martin
var
HTMLLabel: FPHTMLLabelElement; //from frontPage_TLB (almost identical to
mshtml_TLB except for FP Prefix)
LabelEvents: TFrontPageEditorHTMLLabelEvents;// from EventSinkIMpl
begin
HTMlLabel:= fp.ActiveDocument.createElement('Label') AS FPHtmllabelElement;
HtmlLabel.title:='This is frustrating';
HtmlLabel.innerText:='This is really frustrating';
fp.Get_ActiveDocument.Get_activeElement.insertAdjacentHTML('BeforeEnd',HtmlL
abel.InnerHTML);
LabelEvents:= TFrontPageEditorHTMLLabelEvents.Create(Self);
LabelEvents.Connect(HtmlLabel);//I get a runtime error.
LabelEvents.onClick:=ButtonInsertClick;// This is what I want to do but I
get a syntax error since OnClick is defined as: Onclick Event is defined as:
//
function (Sender: TObject): WordBool of object;
Wadood
"Martin Kammann" <mNOka...@intellienceSPAM.comPLEASE> wrote in message
news:3c85a06a_2@dnews...