Norman Czarczinski Guest
|
Posted: Wed Aug 02, 2006 2:17 pm Post subject: Events in TWebbrowser-Elements? |
|
|
Hi,
I use a TWebbrowser (EmbeddedWB) to show a HTML-Page with formular
elements. Now I want implement events that signals me when the users
modify values so I can later make a submit-call.
In the DocumentComplete-event I try following code to get events from
all elements for testing:
doc := htmText.Document as IHTMLDocument2;
iDisp := doc.all;
if assigned(iDisp) then
begin
iDisp.QueryInterface(IHTMLElementCollection, iColl);
if assigned(iColl) then
begin
for i := 0 to iColl.Get_length-1 do
begin
iDisp := iColl.item(i, 0);
iDisp.QueryInterface(IHTMLElement, HTMLElement);
if Assigned(HTMLElement) then
begin
ElementEvents := TMSHTMLHTMLElementEvents.Create(Self);
ElementEvents.Onxxxx := ...
ElementEvents.Connect(HTMLElement);
end;
end;
end;
end;
After a few elements I get an unsupported interface error into the
connect method because the FindConnectionPoint fails. How can I avoid
this and check if a HTMLElement has a HTMLElementEvent-ConnectionPoint?
And why not all HTMLElements have a HTMLElementEvent-ConnectionPoint?
At next I try to get only events from input-elements, but use the basic
HTMLElementEvent (later I want to pool this components):
...
for i := 0 to iColl.Get_length-1 do
begin
iDisp := iColl.item(i, 0);
iDisp.QueryInterface(IHTMLInputElement, HTMLInputElement);
if Assigned(HTMLInputElement) then
begin
iDisp.QueryInterface(IHTMLElement, HTMLElement);
ElementEvents := TMSHTMLHTMLElementEvents.Create(Self);
ElementEvents.Onxxxx := ...
ElementEvents.Connect(HTMLElement);
end;
end;
...
Now it fails for all elements. After the QueryInterface to test for a
IHTMLInputElement the FindConnectionPoint finds no HTMLEventElement. Why
was it destroyed?
How can I get correctly events for textboxes, checkboxes, radiobuttons
and selection-elements?
Bye, and TIA
Norman
--
|\ _,,,---,,_ Norman Czarczinski
/,`.-'`' -. ;-;;,_
|,4- ) )-,_..;\ ( `'-'
'---''(_/--' `-'\_) fL |
|