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 ?
System ProgrammingC++

Avatar of undefined
Last Comment
cgrandgent

8/22/2022 - Mon
ASKER
cgrandgent

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

ASKER
cgrandgent

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
cgrandgent

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck