Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reference a COM exe from itself?
Message
 
To
17/08/2005 11:04:21
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01041632
Message ID:
01041706
Views:
21
>Hi, Hugo
>
>It looks like I wasn't clear enough. I'm sorry and let me try again:
>

Grigore, I doubt is your fault, it is probably my sloppy brain failing to understand, I hate him!

>When I instantiate the exe from command window, with x = CreateObject("TestProj.TestClass"), it works ok, and it exposes its public properties and methods. It doesn't matter at this time if the properties are accessed directly or not. The problem lies elsewhere. The exe shows a form. User can interact with that form, and I need a way to read the values the user wrote in the interface.
>
>I was thinking to set the controlsource of the controls to the public properties of the OLE class, like .ControlSource = "TestClass.MyPublicPEM", but this is not possible, because there is no TestClass instatiated! How to reference the ole class from the instantiated exe?

I still do not understand. I've never created a COM EXE with an interface, and I just tried one and it failed misserable. Can you post your code, and from where you want to retrieve the values of the controls?

FWIW, this is my lame attempt:
loGDTest		= Createobject('GDTest.GDTest') && Works
loGDTest.Show() && No error, but no form displayed
? loGDTest.getPassword() && Works
? loGDTest.getUser() && Works

* Now, my main problem is that I do not understand from where you want to access the values

define class GDTest as myForm OLEPUBLIC
	function getUser() as String
		return this.text1.value
	endfunc
	
	function getPassword() as String
		return this.text2.value
	endfunc
	
	procedure init() as VOID
		this.visible = .t.
		read events
	endproc
enddefine

DEFINE CLASS myForm AS form

	Top = 0
	Left = 0
	Height = 91
	Width = 242
	DoCreate = .T.
	Caption = "Form1"
	_memberdata = ""
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 16, ;
		Top = 34, ;
		Width = 100, ;
		Name = "Text1", ;
		Value = "Default User"


	ADD OBJECT text2 AS textbox WITH ;
		Height = 23, ;
		Left = 137, ;
		Top = 34, ;
		Width = 100, ;
		PasswordChar = "*", ;
		Name = "Text2", ;
		Value = "Default Password"


	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "User", ;
		Height = 17, ;
		Left = 19, ;
		Top = 19, ;
		Width = 29, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Password", ;
		Height = 17, ;
		Left = 138, ;
		Top = 20, ;
		Width = 58, ;
		Name = "Label2"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 65, ;
		Left = 137, ;
		Height = 23, ;
		Width = 100, ;
		Caption = "Exit", ;
		Name = "Command1"


	PROCEDURE command1.Click
		clear events
		quit
	ENDPROC


ENDDEFINE
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform