Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ActiveX exe
Message
 
 
À
24/10/2001 11:48:57
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00572561
Message ID:
00573629
Vues:
20
This message has been marked as the solution to the initial question of the thread.
>I have the clear events line, and when I shut down the exe activated with the createobject() syntax, the original exe can once again function.
>What I want to do is have both exe's running simultaneously, with the 1st automating and controlling the second, much in the same way as Word or outlook can be automated from Foxpro.

Yes you can do this; however, I don't think it will work with the present setup. Instead of having the same code in both the StartExe method and the Main program, change the Main program code to be the following:
local lox, llerror, lcerror
llerror = .F.
lcerror = on('error')
on error llerror = .T.
lox = getobject(,'MyCOMSrv.svcomm')
if !empty(lcerror) then
	on error &lcerror
endif
if llerror then
	* we couldn't get a currently running instance of SVCOMM so 
	* we need to create one
	lox = createobject('MyCOMSrv.svcomm')
endif
if vartype(lox) = "O" then
	lox.StartEXE()
endif
What this does is make sure if a user runs the application the an instance of the class is created and added to the Running Object Table (ROT) (see Note below). If you have code as you had then an instance is not created and you need to use CreateObject. This creates a spearate instance and the two do not communicate.

In addition to the changes in the Main program, you can make the following changes to the StartEXE method:
define class svcomm as custom olepublic
oFormRef = .NULL.
procedure startexe
	if isnull(THIS.oFormRef) then
		do form sv_test.scx name THIS.oFormRef linked
		read events
	else
		THIS.oFormRef.Show()
	endif
endproc
enddefine
This adds an object to the form to a property of your class. If one already exists because someone already created the COM object and ran the StartEXE method, then it simply displays the same form again. The point here is that if a user inputs something into the form, the same information is accessible via object.oFormRef.Control.Value in your code. You can then change it via code and the user will see the changed values on the displayed form.

ROT - A workstation's ROT keeps track of those objects that can be identified by a moniker and that are currently running on the workstation.

NOTE: This only works under VFP 7. See MSKB#Q255683 for an explanation of why this is so.

Good luck!
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform