After creating a project in Visual Studio, you can build and debug it. The following procedures are for Visual Studio 6.0. For the most recent information, read the documentation for version you are using.
Building the Project
Before building your project, you need to establish the project settings. Some of the settings you make depend on whether you want to create a debug or release version of the control or library. As a rule, create debug versions of the program until you are satisfied that it works correctly, then create a release version.
To specify a debug or release version
-
On the Build menu, choose Set Default Configuration.
-
Choose whether you're creating a debug or release version of the control.
-
Choose OK.
To establish project settings
-
From the Build menu, choose Settings.
-
Under Settings For, choose whether you're creating a debug or release version of the program.
-
Click the C/C++ tab and then make these settings:
-
In the Category list, choose Code Generation.
-
In the Calling Convention list, choose _fastcall.
-
In the Use run-time library list, choose Multithreaded DLL.
-
In the Category list, choose Code Generation.
-
Choose the Link tab and then in the Object/Library Modules text box, add one of the following libraries:
-
If you're building an .ocx, add
OCXAPI.LIB
from the Visual FoxPro API directory.
-
If you're building an .fll, add
WINAPIMS.LIB
from the Visual FoxPro API directory.
-
If you're building an .ocx, add
-
Unmark Ignore all default libraries.
-
Choose OK.
To make sure the compiler can find the necessary files
-
From the Tools menu, choose Options.
-
Click the Directories tab.
-
In the Show directories for list, choose Include files.
-
In the Directories toolbar, click the Add button.
-
Add the directory with Pro_ext.h.
-
In the Show directories for list, choose Library files.
-
In the Directories toolbar, click the Add button.
-
Add the directory with Ocxapi.lib from the Visual FoxPro API directory (when creating a control) or add the Winapims.lib from the Visual FoxPro API directory (when creating an FLL)
-
In the Options dialog box, choose OK.
After you've specified the settings, you can compile and link your program.
To compile and link an .ocx file
-
From the Build menu, choose BuildВ projname.ocx.
When you compile and link the .ocx file, Visual C++ automatically registers the control on the computer on which it was built. If for any reason you must register the control manually, you can do so using the following procedure.
To register the ActiveX control
-
From the Tools menu in the Microsoft Development Environment, choose Register Control.
-or-
-
Declare and call DLLRegisterServer(В ) from your program.
Debugging an ActiveX control or FLL library in the context of a full Visual FoxPro application is more difficult than debugging it separately from the application. It's a good idea to create a simple test program to test the operation of your control or library.
Debugging with the Microsoft Development Environment
Microsoft Visual C++ version 4.0 and higher offers an integrated debugging environment that makes it easy to set break points and to step through your code. You can even run Visual FoxPro from Visual C++.
To start debugging with Microsoft Visual C++
-
From the Build menu, choose Settings.
-
In the Project Settings dialog box, click the Debug tab.
-
In the Executable for debug session text box, type the path and name of the Visual FoxPro executable (.exe) file. For example, you can type the following line with the appropriate substitution for the Visual FoxPro version number:
C:\Program Files\Microsoft Visual FoxPro <versionNumber>\Vfp<versionNumber>.exe
-
Choose OK.
-
Set a break point in your library.
-
From the Build menu, choose Debug. Then, from the submenu choose Go.
-
When Visual Studio displays a message that says, " VFP9.exe does not contain debugging information," choose Yes to continue.
For more information about debugging in Visual C++, see the Visual C++ documentation set.
Debugging with Other Debuggers
You should be able to debug a control or library with any debugger that correctly handles an INT 3 (_BreakPoint( )) embedded in your program. You can use any debugger for symbolic debugging as long as it can do all of the following:
-
Make a symbol table from a map file.
-
Load the symbol table independent of the program.
-
Relocate the symbols to a new address.
To debug a library
-
Add a _BreakPoint(В ) call to the routine at the point where debugging will begin.
-
Build the control or library.
-
Invoke your debugger.
-
If your debugger supports symbols, load the symbol table for your library.
-
Start Visual FoxPro.
-
Call your library routine from Visual FoxPro.
-
When the breakpoint is reached, make adjustments to the symbol base to align your symbols with the actual location where the library was loaded.
-
Increment the instruction pointer (IP) register by 1 to skip over the INT 3 instruction.
-
Continue debugging as with a normal program.
Note: Always remove any breakpoints specified in your debugger before you release your product.