Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is my Class going out of scope - How to fix?
Message
From
02/12/2006 18:23:20
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
02/12/2006 16:36:30
Donald Lowrey
Data Technology Corporation
Las Vegas, Nevada, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01174404
Message ID:
01174418
Views:
10
>Good afternoon
>
>I have two class definintions in the same program file, one of which is a timer. When the timer event fires, it calls a method in the first class, which fails. VFP complains it cannot find the called method of a public class, created from an exe ("Object oObjTestCom Not found").
>
>When oObjTestCom is created from the prg file, everything works perfectly.
>
>oObjTestCom = CREATEOBJECT("MyTestCom")   && Everything is ducky, Life is good.
>
>
>But, when compiled into an exe named "MyComExe" and called like this:
>
>oObjTestCom = CREATEOBJECT("MyComExe.MyTestCom")  && Problem. Get coffee refill.
>
>The Object is created, Proc1, Proc2 and ProcCreateTimer all work.
>BUT, when the oMyTimer event fires, VFP errors, complaining it
>cannot find oObjTestCom.
>
>The code below is abbreviated, and I am hoping that someone will be able to spot the problem straight away. Thanks for taking the time to look.
>
>Thanks !
>Don Lowrey
>
>
>File MyTestCom.prg has this (psuedo) code:
>
>Define MyTestCom AS Custom OlePublic
>Procedure Init
>  This.CreateTimer
>EndProc
>Proc1..does stuff..EndProc
>Proc2..does other stuff..EndProc
>Procedure CreateTimer
>  * Tried variations with and without declaring PUBLIC oMyTimer
>  oMyTimer = CREATEOBJECT("MyTimer")
>EndProc
>EndDefine
>
>Define Class MyTimer As Timer  && with and without OlePublic
>  Set Enabled .t. and Interval to an int val, such as 30000
>  Procedure Timer
>    oMyTestCom.Proc2  && This line fails from exe "Object oTestClass Not found"
>  EndProc
>EndDefine
>
>
>Notes: When running from the executable:
>a. We know the class MyTimer gets created because the Timer event fires.
>b. However, from the VFP Object Browser, only the MyTestCom class is shown.
>c. In the DeBug window, oObjTestCom is shown as an object, but the Methods are not exposed. Also oMyTimer is not shown.
>d. We know the exe is running, because it is shown in the Task Manager, Processes Tab.
>*

Shouldn't the timer be a member of the myTestCom class? Try
Procedure CreateTimer
  * Tried variations with and without declaring PUBLIC oMyTimer
  this.addobject("oMyTimer","MyTimer")
EndProc
and in the timer,
procedure timer
   this.parent.proc2()
endproc

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform