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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create a Procedure within an class created within a programme

Status
Not open for further replies.

bebbo

Programmer
Dec 5, 2000
621
GB
I have spent some time on trying to create an DataEvent Procedure within an object made within a program, see below.

addobject("MCRST","OLECONTROL","OPOS.MSR")

I have read the microsoft help and looked at the define class. Unfortunately I don not know if I looking in the right area. I use "addobject" to create a number of OPOS classes. This works fine but I would like to know how to add a procedure. Thanks
 
Proceudres are defined w/i a class so long as you define the proceedure w/i the DEFINE CLASS ... ENDDEFINE you should be ok.

You call the proceedure the same way as a method on other objects.... objectname.procedurename(parameters)

from VFP help...
DEFINE CLASS ClassName1 AS ParentClass [OLEPUBLIC]
[[PROTECTED | HIDDEN PropertyName1, PropertyName2 ...]
[Object.]PropertyName = eExpression ...]
[ADD OBJECT [PROTECTED] ObjectName AS ClassName2 [NOINIT]
[WITH cPropertylist]]...
[[PROTECTED | HIDDEN] FUNCTION | PROCEDURE Name[_ACCESS | _ASSIGN]
| THIS_ACCESS [NODEFAULT]
cStatements
[ENDFUNC | ENDPROC]]...
ENDDEFINE

Perhaps I'm misunderstanding your question?

Pete
blindpete@mail.com

What your mother told you is true! You will go blind! (from moonshine anyway)
 
Thanks for replying. I have actually been trying to use the example from the foxpro help. unfortunately with not much success. Basically what I am trying to do is to create a OPOS MSR Control during run time with a DataEvent Procedure. I have used the following code to create the control but how do I add the event. Am I missing something obvious?

addobject("MCRST","OLEControl","OPOS.MSR")

The main reason for adding the control during run time is that sometimes the drivers which run this control are either missing or in correct. If this is the case my program freezes. Therefore the addobject program is controlled by a Logical Flag. Hope someone can help!!!!
 
Good question, I wish I knew the answer.

You don't have to 'add' the DataEvent; it's one of the common events of an OPOS control. See also chapter 1 of the OPOS Application Programmers Guide.

However, VFP has problems with events/errors from COM-objects. A possible solution could be the usage of VFPCOM

Good luck!
Diederik Vermeeren
verm1864@exact.nl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top