I'm using the MFC web browser control in my dialog-based MFC project to display some HTML content and I am trying to make it show the "Find on page" dialog window with the search word already pre-selected in it. (What you'd get if you hit Ctrl+F in the IE web browser.)
If I do the following the find dialog is shown OK, but it doesn't seem to support a way to pre-fill the search word:
IWebBrowser2* pWebBrowser = NULL;
LPUNKNOWN unknown = m_browser.GetControlUnknown();
unknown->QueryInterface(IID_IWebBrowser2,(void **)&pWebBrowser);
if(pWebBrowser)
{
HRESULT hr;
CComVariant varNull;
if(SUCCEEDED(hr = pWebBrowser->ExecWB(OLECMDID_FIND, OLECMDEXECOPT_PROMPTUSER, &varNull, &varNull)))
{
//Success!
}
pWebBrowser->Release();
}
if(unknown)
{
unknown->Release();
}
I found this MSDN page, that says:
OLECMDID_SHOWFIND Tells the receiver to show the Find dialog box. It takes a VT_DISPATCH input param.
So evidently there's another Find command with OLECMDID_SHOWFIND
ID, but I can't seem to make it work. I don't understand what is this VT_DISPATCH
input param either? When I try this -- a total shot in the dark due to the lack of documentation:
CComVariant var1 = L"Pre-filled search word 1", var2 = L"Pre-filled search word 2";
hr = pWebBrowser->ExecWB(OLECMDID_SHOWFIND, OLECMDEXECOPT_DODEFAULT, &var1, &var2);
but I get hr=0x80040100
or "Trying to revoke a drop target that has not been registered"
Any idea how to make it work?
User contributions licensed under CC BY-SA 3.0