Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding a procedure to an ActiveX control
Message
 
 
To
29/06/2000 11:39:35
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00386187
Message ID:
00386497
Views:
22
You can do much the same thing using VFPCOM. Two methods of this object are ExportEvents and BindEvents.

ExportEvents allows you to specify an object and have all of its events exported to a file in the form of a custom class definition, one procedure per event.

You can create an instane of this new object and an instance of the ActiveX control and use the BindEvents method of the VFPCOM object to link them. Whenever an event fires in the ActiveX control, the corresponding event in your custom class will fire, running your code.

This technique works well when you don't want need a container to hold the ActiveX object (e.g. Word, Excel).

>Hi Larry,
> Just wanted to say thanks for the assistance.
>
> And also, defining classes in that way, allows you to programmatically add code to the event procedures of an ActiveX control, making it unnecessary to hard-wire your code directly in the event procedure at design time. No need for a class library either.
>
>Thanks again.
>
>Jon
>
>>Hi Jon,
>>First off, I want to thank for pointing out something new to me. I didn't know you could specify the syntax for class definitions in that way.
>>
>>As for your question, the method is definitely running as a result of the control instantiating and not the form. To test this, add the NOINIT keyword to the end of the ADD OBJECT Manager line of code. This will tell VFP to add the new object but not run its Init. Since the Olecontrol's Init doesn't run, your Manager.Init code doesn't run proving it is linked to the object.
>>
>>Thanks.
>>
>>>Hi Larry,
>>> Thanks for the reply, although it wasnt what I hoped to hear.
>>>
>>>>No it doesn't. Add the Init method under the OleManager class definition.
>>>
>>> According to the example under the DEFINE CLASS command in the help file, anything I add under the OleManager class definition is added to the OLE Container unless it is prefaced with the .Object clause, and I couldnt figure out how to create a procedure using the .Object clause.
>>>
>>>>Most likely, the Manager.Init line of code will throw an error.
>>>
>>> The Manager.Init line doesnt throw an error and in fact, executes when the object initializes. But is there a way to determine if the procedure is executing for the OLE Container or the ActiveX control?
>>>
>>>Jon
>>>
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform