Re: IWebBrowser2 wrapper and KeyUp/KeyDown
- From: Sergey Bogdanov <sergey.bogdanov@xxxxxxxxx>
- Date: Fri, 16 Sep 2005 13:28:56 +0300
You have to consider IOleInPlaceActiveObject interface which provides communication between browser and host window. Then forward key/mouse messages to IWebBrowser2 control from CF application by using TranslateAccelerator method of IOleInPlaceActiveObject interface:
IWebBrowser2* m_pBrowserApp; ....
extern "C" _declspec(dllexport) BOOL TranslateBrowserAccelerator(MSG *pMsg)
{
IOleInPlaceActiveObject* pIOIPAO;
HRESULT hr = m_pBrowserApp->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pIOIPAO);
BOOL bRet = FALSE;
if (SUCCEEDED(hr))
{
bRet = pIOIPAO->TranslateAccelerator(pMsg) == S_OK ? TRUE : FALSE;
pIOIPAO->Release();
}return bRet; }
Then in C# application using IMessageFilter from SDF to trap WM_KEY*/WM_MOUSE* events and pass it into TranslateBrowserAccelerator method to inquire browser processed message or did not. Here you are a code snippet of IMessageFilter.PreFilterMessage:
if ((m.Msg < WM_KEYFIRST || m.Msg > WM_KEYLAST) && (m.Msg < WM_MOUSEFIRST || m.Msg > WM_MOUSELAST)) return false;
if (!IsChild(m.HWnd)) return false;
MSG msg = new MSG(); msg.hwnd = m.HWnd; msg.lParam = m.LParam; msg.wParam = m.WParam; msg.message = m.Msg;
return _htmlViewer.TranslateAccelerator(ref msg);
HTH
-- Sergey Bogdanov [.NET CF MVP, MCSD] http://www.sergeybogdanov.com
JohnL wrote:
Hello,
not sure that this is correct newsgroup but since the probrem related to CompactFramework application I decided to write here.
Well, after small introduction here is the issue. I have IWebBrowser2 wrapper written in eVC and also have CF application that uses it. This is strange but HTML inside this WebBrowser does not receive KeyDown/KeyUp events and works like a charm inside standard IE.
Does anybody know how to solve it?
Thank you for all suggestions in advance!
.
- Follow-Ups:
- Re: IWebBrowser2 wrapper and KeyUp/KeyDown
- From: JohnL
- Re: IWebBrowser2 wrapper and KeyUp/KeyDown
- References:
- IWebBrowser2 wrapper and KeyUp/KeyDown
- From: JohnL
- IWebBrowser2 wrapper and KeyUp/KeyDown
- Prev by Date: Re: Strange discovery
- Next by Date: "ActiveX Server EXE" on Windows CE?
- Previous by thread: IWebBrowser2 wrapper and KeyUp/KeyDown
- Next by thread: Re: IWebBrowser2 wrapper and KeyUp/KeyDown
- Index(es):