Without a single change in the source code, we can migrate this sample project from Delphi 7 to Delphi for .NET. The new executable is a safe executable, which can be proved by running it through PEVerify without errors. When you close the project, a FontDraw.bdsproj is generated, and some configuration settings are written to the FontDraw.cfg file. Fortunately, these new settings do not prevent Delphi 7 from being able to compile the same project.

One change made by Delphi for .NET to the main unit is the addition of the System.ComponentModel unit to the uses clause of the interface section. Slightly modify this uses clause if you want to keep a single-source cross-platform project. Place the System.ComponentModel unit in a {$IFDEF CLR} section, like this:


Windows, Classes, Graphics, Forms, Controls, {$IFDEF CLR} System.ComponentModel, {$ENDIF} StdCtrls;

This single change is something you must perform for all units migrating from Delphi 7 to Delphi for .NET, for which you want to enable compatibility with Delphi 7 (to produce a Win32 executable as well as a .NET executable from the same project source code).


The Ownerlist sample application worked easily and took only one manual step. Let's take another example, the first one used to demonstrate the capabilities of the Delphi for .NET preview command-line compiler: ConvertIt. The Demos\ConvertIt directory contains five files: ConvertIt.dpr and ConvertItres, ConvertItUnit.pas and ConverItUnit.dfm, and a EuroConv.pas unit.

This project also loads immediately in the Delphi for .NET IDE, and results in another native .NET executable (Figure 3).

Was this article helpful?

0 0

Post a comment