Freigeben über


Building and Debugging Libraries and ActiveX Controls

After creating a project, you're ready to build and debug it.

Building the Project

Before building, 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, you create debug versions of the program until you're satisfied that it's working correctly, and then you create a release version.

To specify a debug or release version

  1. From the Build menu, choose Set Default Configuration.
  2. Choose whether you're creating a debug or release version of the control.
  3. Choose OK.

To establish project settings

  1. From the Build menu, choose Settings.
  2. Under Settings For, choose whether you're creating a debug or release version of the program.
  3. 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.
  4. 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.
  5. Unmark Ignore all default libraries.
  6. Choose OK.

To make sure the compiler can find the necessary files

  1. From the Tools menu, choose Options.
  2. Click the Directories tab.
  3. In the Show directories for list, choose Include files.
  4. In the Directories toolbar, click the Add button.
  5. Add the directory with Pro_ext.h.
  6. In the Show directories for list, choose Library files.
  7. In the Directories toolbar, click the Add button.
  8. 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)
  9. 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 Buildprojname**.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

Debugging the control or 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++

  1. From the Build menu, choose Settings.

  2. In the Project Settings dialog box, click the Debug tab.

  3. In the Executable for debug session text box, type the path followed by Vfp7.exe.

    For example, type: C:\Program Files\Microsoft Visual FoxPro 7.0\Vfp7f.exe.

  4. Choose OK.

  5. Set a break point in your library.

  6. From the Build menu, choose Debug. Then, from the submenu choose Go.

  7. When Visual Studio displays a message that says "Vfp7.exe doesn't 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

  1. Add a _BreakPoint( ) call to the routine at the point where debugging will begin.

  2. Build the control or library.

  3. Invoke your debugger.

  4. If your debugger supports symbols, load the symbol table for your library.

  5. Start Visual FoxPro.

  6. Call your library routine from Visual FoxPro.

  7. When the breakpoint is reached, make adjustments to the symbol base to align your symbols with the actual location where the library was loaded.

  8. Increment the instruction pointer (IP) register by 1 to skip over the INT 3 instruction.

  9. Continue debugging as with a normal program.

    Note   Always remove any breakpoints specified in your debugger before you release your product.

See Also

Managing Memory | Access to Visual FoxPro Variables and Fields | Accessing the Visual FoxPro API | Extending Visual FoxPro with External Libraries | Return of a Value to Visual FoxPro