Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AddObject problem
Message
 
À
18/06/2002 08:25:36
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00669545
Message ID:
00669941
Vues:
16
Hi

Thanks for the help. I tried
DEFINE CLASS Interface AS CUSTOM OLEPUBLIC

PROCEDURE InterInit 
PARAMETERS pForm as Form
	SET CLASSLIB TO Attaché.vcx
	WITH pForm
		.NewObject('InterOpts','interopt',"Attaché.vcx",'d1.dll')
		.myContainer.visible=.T.
	ENDWITH
	RETURN 'InterOpts'
ENDPROC
ENDDEFINE
but it gives me an error saying that it cannot find the DLL. This is odd because the DLL does exist in the location that the error specifies.

I thought it might be because I am using the DLL that it cannot find it but when I created a copy (d2.dll) it could not find that either.


then I tried
	.NewObject('InterOpts','interopt','Attaché.vcx','Attaché.app')
and compiled my project as an .app. instead. This works, as it also does for exe.

It would appear that I cannot use a DLL. This seems to be a bit of an oversight.

Unfortunately, I need the DLL/object to exist independantly of the form (i.e. the form does not always exist) yet the underlying functions for each interface are necessary at all times as they will be accessed from an activeX event. In order to do this with an app or exe I have to
PUBLIC oInter
oInter=NEWOBJECT('interface','Attaché.app')
and can then
oInter.InterInit(thisform)
when the form requiring the options is created.

It would be nice to do this from within a DLL instead of an app or exe so any ideas as to what I might be doing wrong with the DLL or how I can instantiate from within my DLL (eg. why it cannot find the DLL even though it is in the directory where the error says it cannot find it) would be greatfully received.

By and large I am looking for a solution that totally encapulates each interface.



Regards
Geoff Scott


>Hi Geoff,
>this is a little bit on my english limits, so I try to understand:
>I do three interpretations
>
>1.
>Do you mean you have an exe and like to excerpt a class out off the dll to use it inside an form out of the exe?
>
>try
>.NewObject('myContainer','interopt',"gen.vcx",'d1.dll')
>
>Try to add a path to 'd1.dll' as well.
>
>Have a close look the help to NEWOBJECT. There are tricky things in the way wich vcx is used.
>
>If you succeed to extract out of an dll, please send a message, I would like to do a similar thing.
>
>2.
>Or other try to translate:
>
>means:
>"..but leaves my class definition outside my DLL"
>
>that "gen.vcx" is not automated included to the project?
>
>automatic adding a classlib to a project works only for
>
>set classlib to
>
>and if the classlib holds a parentclass
>
>
>set classlib to my_first.vcx
>
>will add my_first.vcx
>
>
>lcClass = my_first.vcx
>set classlib to &lcClass
>
>will not, because the compiler can not look into a lcClass.
>
>NEWOBJECT(,,cModule) is not resolved to "Add cModule to the project" by the compiler.
>
>3.
>Or this is all in the same dll?
>
>
>>.NewObject('myContainer','interopt','gen')
>
>works.
>So why is "gen" outside the dll? It should be inside if the vcx is compiled into the dll.
>(the vcx is listet into projectmanager and not excluded)
>
>How do you determeine that the call above calls outside the dll?
>
>Refer NEWOBJECT's Help for a list of how NEWOBJECT searches for a class.
>
>If it will not work, my last guess is to rename "gen.vcx" , sometimes the fox is sensitiv to some strings.(I spend days on a view called "selection" - it works after rename)
>"gen" may be of internal use.
>
>HTH
>Agnes
>>Okay, almost there.
>>
>>The final step, encpulation.
>>
>>
>>WITH pForm
>>	.NewObject('myContainer','interopt','gen')
>>	.myContainer.visible=.T.
>>	.myContainer.top=15
>>	.myContainer.left=15
>>ENDWITH
>>
>>
>>works great but leaves my class definition outside my DLL
>>
>>I have the class library gen in my project d1
>>
>>I tried
>>
>>
>>
>>	.NewObject('myContainer','interopt','d1.dll')
>>
>>
>>but alas it errors
>>
>>How do I reference an object within a class library within my dll or is it that I have not properly included the class definition within my DLL???
>>
>>Regards
>>Geoff Scott
>>
>>
>>>Hi Geoff,
>>>
>>>I have never done this with a DLL, but have you tested NewObject() method? There is a third parameter for source.
>>>
>>>Agnes
>>>>Hi
>>>>
>>>>How do I reference an object within a class library in a DLL.
>>>>
>>>>I can do
>>>>
>>>>
>>>>WITH pForm
>>>>	.AddObject('myContainer','Container')  &&Add Container to form
>>>>	.myContainer.visible=.T.
>>>>ENDWITH
>>>>
>>>>
>>>> where I pass pForm to my DLL, but I cannot do
>>>>
>>>>
>>>>SET CLASSLIB TO 's:\pc source\gen.vcx' ADDITIVE
>>>>WITH pForm
>>>>	.AddObject('myContainer','interopt')  &&Add Container to form
>>>>	.myContainer.visible=.T.
>>>>ENDWITH
>>>>
>>>>
>>>>where interopt is a container object defined in gen.vcx.
>>>>
>>>>It works fine when not in a DLL but gives me an OLE IDispatch Error 733 telling me Class definition INTEROPT is not defined when I try to use it in a DLL.
>>>>
>>>>Can anyone tell me what I am doing wrong?
>>>>
>>>>regards
>>>>Geoff Scott
May all your weeds be wildflowers
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform