1. Computing

How to Debug Delphi VCL Source Code (Set a Breakpoint in the VCL)

Set a Breakpoint in the VCL Source Code

By

Debug Delphi VCL Source Code

Debug Delphi VCL Source Code

No matter how careful you are when writing code, your programs are likely to contain errors, or bugs, that prevent them from running the way you intended. Debugging is the process of locating and fixing errors in your programs.

One way to locating errors while designing your code is to use the integrated debuger. If you set a breakpoint on a line in your source code, the line that contains the breakpoint appears in the Code editor highlighted.

A location in your program's source code where you want the execution to stop is called a breakpoint.

Debugging FORMS.PAS, SYSUTILS.PAS or SYSTEM.PAS

What if you need to "dive" into the source code Delphi controls are made of? What if you need to step through the CreateParams method of the TCustomForm class?

Luckily, the Delphi IDE allows you to set the breakpoint in the VCL source code units.

Here's how enable debugging VCL and RTL source code:

  1. Select "Project - Options" from the main IDE menu
  2. Select "Compiler" section on the "Project Options for [ProjectName].exe"
  3. Locate the "Debugging" group box,
  4. Make sure the "USE DEBUG DCUs" check box is checked!
  5. Set the breakpoint somewhere in the TCustomForm's CreateParams method, for example.
  6. Start the application ...

Note: if you have a Delphi version that comes with the source code (YES! some Delphi versions include the full VCL / RTL source code), you can easily browse through it! Here's How to Browse Delphi's VCL Source Code.

Delphi tips navigator:
» Disable Automatic Hint Feature for the TTreeView
« Parsing Command Line Parameters with Delphi

©2014 About.com. All rights reserved.