Link to home
Start Free TrialLog in
Avatar of cgrandgent
cgrandgent

asked on

how to paste into browser control Find box, or pre-stuff it with search string ?

I have launched a Find box for a IWebBrowser2 control via ExecWB(OLECMDID_FIND........
I have copied the search string to the clipboard, and wish to paste it into the Find box (a better alternative would be to specify the search string at ExecWB time).
I have enumerated the windows and located the window so I could make sure it has focus.
It apparently is maybe CDHtmlDialog and not a regular text window.
If from the keyboard I do CTL-V or right-click and select "paste", it pastes in OK, but doing it via keybd_event() or SendInput() doesn't do the trick, nor does SendMessage(hwnd,WM_PASTE,0,0).
How to work this magic ?
Avatar of cgrandgent
cgrandgent

ASKER

update on this.
From the code at http://support.microsoft.com/kb/249232 I have been able to derive the IHTMLDocument2 for the Find box from the HWND that I got by enumerating the windows.  From that I've been able to get as far as getting the text from the Find box:
InnerText = 0x024ff324 "Find:  
 Match whole word only  Match case
  PreviousNext "

Now, how to insert the text I have on the clipboard into this document element ?
				LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
				if ( pfObjectFromLresult != NULL )
				{
					HRESULT hr;
					hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc );
					if ( SUCCEEDED(hr) )
					{
						spDoc->QueryInterface(IID_IHTMLDocument2,(void**)&doc);
						doc->put_bgColor(CComVariant("red"));
						doc->put_title(BSTR("red"));
						doc->get_body(&p);
						p->get_innerText(&InnerText);

Open in new window

OK, a little further.
I got the HTML from the Find box and stuck it here:  http://www.chuckg.com/find.htm
If you look at the source for that page, you'll see I need to set the focus for
<INPUT id=txtFindText
and then paste what I have on the clipboard in there.
Still looking for someone who give me a pointer how.
ASKER CERTIFIED SOLUTION
Avatar of cgrandgent
cgrandgent

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial