Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Explorer Active X in VFP 9 Form 2

Status
Not open for further replies.

GuitarSlayer

Programmer
Dec 16, 2004
29
0
0
GB
Hi,

I am displaying an htm file within a VFP 9 form using the Explorer Active X control shipped with VFP.

However I am using the Keyboard command to try and activate the 'Find' dialog on form instantiation, the frustarting thing is that the Keyboard command i am, using (Keyboard '{CTRL+F}')
is not activating the dialog, but if I manually try this command it works fine! I am confused.
 

Hi GuitarSlayer,

What do you mean by "the Explorer ActiveX"? I don't recognise that as one of the ActiveX controls that come with VFP.

In general, you can't use the KEYBOARD command to send keystrokes to an ActiveX control. The command only sends keys to the VFP keyboard buffer.

Do you by any chance mean the Web Browser control? If so, the best way to solve your problem is to call the control's ExecWB method, passing a reference to Find command that you want to execute. You'll find details in the documentation, but if you get stuck, come back.

If it's not the web browser control, perhaps you can be more specific.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, sorry Its been a long day, you are right its the web browser control I am bimbling on about, thanks for your reply but where do i find the documentation.
 
where do i find the documentation.

This might be a good place to start:

Visual FoxPro 9.0 Language Reference
Web Browser Control Foundation Class

This subclass of the Microsoft Internet Explorer browser control provides hooks for Visual FoxPro code and can be added to a Visual FoxPro form.

Class
_Webbrowser4

Class Library
_webview.vcx

Sample
...\Samples\Solution\Ffc\Webvwr.scx



Marcia G. Akins
 
Marcia, thank you very much for your help, I'll get to it right away.
 
Mike, thanks I would gladly tell you if it works, but I have had a quick look at the link you provided me with and to be honest its blinding me with science, thanks anyway.
 

GuitarSlayer,

I agree the wording of the documentation is a little obscure. The important things to focus on are the first two parameters to ExecWB().

With the help of the VFP object browser, I discovered that the first param is 42 and the second is 0. As far as I know, you don't need to worry about the other two params.

If that's right, the code you need to invoke the Find dialogue will be:

THISFORM.MyBrowser.ExecWB(42,0)

I haven't tested that, so can't guarantee that it's right.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Thanks, I was using values 32,0 and was getting a search page as opposed to a dialog, however I got an error after I closed the form 'OLE Error code Trying to revoke a drop target that has not been registered'. I tried your suggested values and I got the same error, and no search dialog. I'll keep battling.

Thanks again.
 
Mike,

I have my suspicions but could it be that calls I am making to the EXECWB method are not compatible with browser control I am using?
 

GuitarSlayer,

I suppose that's possible. That said, ExecWB has been available for many years, although I don't know if all the parameter values have always been available.

Which version of Internet Explorer are you using? Mine is 6.0. The web browser control is essentially Internet Explorer, which is why I asked.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

I am using IE6 and web browser control (Shell.Explorer.2)

Mark
 
GuitarSlayer,

Interesting problem. Here is a runnable example for doing this. The code that makes this possible (along with some of my notes as I worked this out) is in the Command1.Click method. Cut-and-paste the code below into a prg file in VFP and execute it.
Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	WindowState = 2

	ADD OBJECT olecontrol1 AS olecontrol WITH ;
		Top = 0, ;
		Left = 0, ;
		Height = 204, ;
		Width = 375, ;
		Anchor = 15, ;
		Name = "Olecontrol1", ;
		OleClass = "Shell.Explorer.2"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 215, ;
		Left = 276, ;
		Height = 27, ;
		Width = 84, ;
		Anchor = 12, ;
		Caption = "Find", ;
		Name = "Command1"

	PROCEDURE olecontrol1.Init
		this.navigate("[URL unfurl="true"]http://www.sweetpotatosoftware.com/spsblog")[/URL]
	ENDPROC

	PROCEDURE command1.Click
		LOCAL loDoc
		loDoc = THISFORM.Olecontrol1.object.Document
		loDoc.focus() && document must have focus

		*!* Use API calls to simulate CTRL + F
		#DEFINE KEYEVENTF_KEYUP 0x02
		#DEFINE VK_CONTROL 0x11
		
		DECLARE INTEGER keybd_event IN Win32API ;
		      INTEGER, INTEGER, INTEGER, INTEGER

		DOEVENTS && make sure everything else is done 
		keybd_event(VK_CONTROL, 0, 0, 0)
		keybd_event(0x46, 0, 0, 0) && 0x46 is 'f'
		keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
		DOEVENTS && make sure it sends the keys right now 
		
		CLEAR DLLS "keybd_event"
		*!* Keyboard doesn't work here
		*!*	KEYBOARD '{CTRL+F}'

		*!* We could have used Windows Script instead though
		*!*	WshShell = CreateObject("WScript.Shell")
		*!*	WshShell.SendKeys("^f")

		*!* OTHER DEV NOTES OF INTEREST *!*

		*!* ExecWB throws the following exception:
		*!*	'OLE Error code Trying to revoke a drop target that has not been registered'
		*!*	THISFORM.Olecontrol1.ExecWB(42,0)

		*!* For some reason Microsoft didn't implement
		*!* the find dialog for execCommand
		*!* List of supported command identifiers can be found at:
		*!*	[URL unfurl="true"]http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/commandids.asp[/URL]
		*!*	loDoc.execCommand("Find") && this doesn't work, but others will
	ENDPROC
	
ENDDEFINE

boyd.gif

SweetPotato Software Website
My Blog
 
Craigsboyd,

Thanks man, excellent, I'll try and implement this today!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top