0

If a TWebBrowser is put into DesignMode (HTMLDocument2.designMode := 'On';), is there a way to detect changes to the document when a user types in the control, similar to an OnChange event of std ctrls like TEdit/TMemo?

Thanks

RaelB
  • 3,301
  • 5
  • 35
  • 55

1 Answers1

2

This is quite straightforward to achieve once you impl the IHTMLEditDesigner interface and hook it to the WebBrowser (you should be able to find resources on how to do this on the web).

Then the key part is to use the PreHandleEvent:

function TWebBrowserFrame.PreHandleEvent(inEvtDispId: Integer;
  const pIEventObj: IHTMLEventObj): HResult;
begin
  Result := S_FALSE;
  If inEvtDispId = DISPID_EVMETH_ONKEYDOWN Then
      ...
  if pIEventObj.keyCode = ... etc...
end;

This page had some useful info: (where DISPID constants come from...) http://www.codeproject.com/Articles/6546/Using-IHTMLEditDesigner

RaelB
  • 3,301
  • 5
  • 35
  • 55