Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot find VCX inside exe
Message
 
To
27/08/2008 16:42:49
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01342362
Message ID:
01342470
Views:
14
Hi Oscar,

>However, if I happen to call a SECOND (scx) form from the first, the VCX and BMPs contained in the exe are no longer visible

That problem is called application or project scope. Every piece of compiled code in VFP keeps track from which EXE or APP file it has been loaded from. When code is executed and a file name needs to be resolved, VFP only searches in the project scope of the code and in all external locations. In your code this means:

DO FORM line (scoped to EXE)
SCX 1 (no project scope)
SCX 2 (no project scope)

The entire initialization of the form is executed in the scope of the EXE during the DO FORM line. Therefore, the first form finds all classes and image files. However, as the SCX itself is external, none of its code is scoped to an EXE or APP. Consequently, none of the code in this form is able to see files in the EXE. The second form call fails.

There are some exceptions to this when VFP uses existing classes from the cache or existing PRG files from the compiled code cache. But you shouldn't rely on this.This problem comes up in other scenarios, as well, like combining EXECSCRIPT() calls, etc. There are some more information on my web site: http://www.foxpert.com/knowlbits_200707_4.htm.

As a solution you need to make sure that the DO FORM line is executed inside the APP scope. The easiest one would be to crea a program DoForm.PRG and embed it into your application. Then run new forms with:
DO DoForm.prg IN whatever.EXE WIITH "myform.SCX",...
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform