Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with element event handling of WebBrowser Control

25 views
Skip to first unread message

ja...@126.com

unread,
Jan 10, 2008, 11:42:46 PM1/10/08
to
Hi, my program uses a WebBrowser Control with the following code:


HRESULT hr = CoCreateInstance(CLSID_WebBrowser,
NULL,
CLSCTX_INPROC,
IID_IWebBrowser,
(void**)&m_spWebBrowser);


Then I navigate the control to a local html file, which contains some
type text inputs, the code is like this;
<span contentEditable="true"></span>


Upon the load completion, I attached a render behevior for each
element, the definition is list below:

class ATL_NO_VTABLE CIdsUISpanRB :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CIdsUISpanRB, &CLSID_IdsUISpanRB>,
public IDispatchImpl<IIdsUISpanRB, &IID_IIdsUISpanRB,
&LIBID_IdsViewer>,
public IElementBehavior,
public IElementBehaviorFactory,
public IHTMLPainter


The render behavior above implemented an event sink, I conneted it
with the webbrowser control by AtlAdvise:
hr = AtlAdvise(m_spElem, (IDispatch*)this, // m_spElem is the element
DIID_HTMLElementEvents2,
&m_dwCookie);


What I want to do, is to process the input event within the invoke
method of IDispatch interface:

STDMETHODIMP CIdsUISpanRB::Invoke( DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pdispparams,
VARIANT* pvarResult,
EXCEPINFO* pexcepinfo,
UINT* puArgErr)
{
switch (dispidMember)
{
case DISPID_HTMLDOCUMENTEVENTS_ONKEYDOWN:
{
// my handling code, the problem here is that the keydown event
// never happens, instead, I can only get keypress event here.
break;
}
}
}


The problem I have, is that I can't get keydown or keyup event, but
only keypress message, so any one can tell me why? how to get the
keydown event?

Another thing, I attached an edit designer to the whole html docuement
mentioned above, in order to handle events within the html doc. Within
the edit designer, I can get keydown event, but no keyup.
moreover, as docuemented, the TranslateAccelerator method of
IEditDesigner, will be called first if any keyboard event triggered,
but acutally this function was never called even I press the keyborad,
what's wrong?

0 new messages