Upgrade to Delphi 6 - Compatibility (Chinese Full ...

zhaozj2021-02-11  194

Upgrade to Delphi 6

Original: Borland Corporation

Translation: MusicWind®

Date: 2001-07-11

statement:

The content of the following article takes the help document that comes with Delphi 6.

Copyright Borland Corporation.

Translation This draft has not been approved by Borland in advance, and Borland will forgive.

General rule

Open the Delphi 5 (or earlier) project, the new version will automatically upgrade it. What will be described below is some modifications that may have potentially impact on existing Delphi projects in the new version.

Ide (integrated development environment) features

Automatic update of package name

Compatibility problem

For more information, please refer to the content of "Delphi6 New Features".

Compatibility problem

What is listed below is possible to affect a few big aspects of your Delphi application:

One. Changes in some events of Provider and Client Dataset due to changes in VCL architecture

The introduction of TCustomClientDataSet makes some changes in the event handling mechanism in Delphi 5 or earlier versions.

There are five types of six events in dbclient.pas units, they are:

Event type change

TRESOLVERROREVENT affects the ONUPDATEERROR event of the Provider.

TbeForeUpdateRecordEvent affects the BeforeUpDateRecord event of the Provider.

TAFTERUPDATERECORDEVENT affects the AfterUpDateRecord event of the Provider.

TPROVIDERDATAEVENT affects the ONGETDATA AND ONUPDATEDATA event of the Provider.

TRECONCILEERROREVENT affects the onReconcileError event in Client Dataset.

The TclientDataSet in the process function (procedure) mentioned above must be replaced with TCUSTOMCLIENTDATASET.

two. Changes in the code to log in to the default database

Originally, a LoginPrompt property of a connection component (such as TDatabase, TadoConnection, or TDCOMConnection) is set to True, the default login dialog popping out. This feature is no longer reserved unless you add a statement that reference dblogdlg in unit reference. If you want an application to still pop up the default login dialog, be sure to add this dblogdlg, otherwise there will be no prompts to enter the username and password dialog box.

three. Potential binary FORM file is not compatible

In the past, the binary form file (or DFM file) created by the new version Delphi can be read by the old version of Delphi. But now it is fine. Some binary form files may not be read correctly by the old version because the streaming of the strings inside Delphi 6 is originally different. In the past, fluidization operation assumed a local special character set. Now the new fluidization operation assumes the character set to UTF-8. The problem that caused this is that if the Delphi 6 contains characters that contain the code value greater than 127 (such as copyright index ®) in the binary Form file, the file cannot be read correctly by Delphi's old version.

If you want to open the FORM file of Delphi 6 in the old version of Delphi, please give the Form file as a text format instead of two-in format. four. Configurable constant

Compile Macro $ WriteableConst The current default is customized (OFF), which is to prevent the use of the canable constant in the engineering of Delphi. The conferred constant is also defined a constant, but it allows it to change its value during operation. The example is as follows:

Const

Foo: integer = 12;

Begin

Foo: = 14;

End.

In the past Delphi version, there is such a characteristic: constant is not true constant. Using the compilation macro $ WriteableConst off, the FOO assignment in the above code will trigger a compilation error. To avoid this error, you can change the declaration of the foo to VAR.

Using constants as a local variable that can be initialized, such code is as follows:

PROCEDURE MyProc;

Const

Somedata: integer = 12;

Begin

INC (Somedata, 3);

END;

Now you have to do to move the statement of local constants to the outside of the process, making it a global variable. Then the code becomes:

VAR

Somedata: integer = 12;

PROCEDURE MyProc;

Begin

INC (Somedata, 3);

END;

For excessive depends on constant codes (such as the Package of the ActiveX control), you can correct it inserted into a {$ WriteableConst on} in the source file. This feature is forbidden in the source code such as RTL, VCL, CLX, and DB, but can be accepted in the package of the periphery, such as the package of the ActiveX control.

All in all, you should realize the self-contradictory contradictions of "can assignable constants". This feature in Delphi's previous version is just to keep it compatible with the old 16-bit compiler, but now this is meaningless to Delphi developers. In addition, to develop good program habits, we should try to avoid the use of "can assignable constants."

Fives. Cardinal type negative value

In the past, the 32-bit mechanism was used when Delphi handled the negative value of the Cardinal type, which made the result for some zero-headed values ​​(the maximum value of the Cardinal type and the difference between the current value). The example is as follows:

VAR

C: cardinal;

i: int64;

Begin

C: = 4294967294;

I: = -C;

Writeln (i);

END;

In the past version of Delphi, the value of i should be 2. But it is not the case now. In Delphi 6, the Cardinal type is a symbol type that is converted to a 64-bit and then performs the calculation of the negative value, so the value of the final result i is -4294967294.

Some of the code may depend on the implementation method of the original error, so I hope the reader has attracted enough attention to this new feature of Delphi. Flowering enough time to verify that there is a case where there is a value for the value of the Cardianl type, it is sure that this new feature of Delphi does not have an impact on your programs.

six. Unit DSGnintf rename and related changes

For DSGnintf's references, you need to change to a new unit reference: DesignIntf. There may be a few units in your reference list in the form of DESIGNEDITORS, Editors, and RTLConsts. In addition, you have to add Designide to the list of Requires of your package. In addition, the reference to the DSNIDE 50 may have to change to Designide if Delphi does not automatically change. Any running period that references Idesigner needs to be changed to Idesignerhook to prevent the requirements of the DesignIDE unit when the runtime. In the runtime code, the iDesignerhook function is sufficient, there is no need to worry. Idesigner can be used when designing period, as follows:

VAR

RealDesigner: Idesigner;

...

Somedesignerhook.QueryInterface (Idesigner, RealDesigner);

...

To get the interface of the iDesigner provided by Idesignerhook. The use of IdesineRhook only needs to reference the Classes and Forms two units. However, Idesigner has to add a DesignInTF unit, since the unit is included in many other packets, and some of them may not be secondary.

Seven. Changes in component editing

In Delphi 6, the TcomponiteTeditor class has different ancestors. In Delphi 5, it from TinterFaceDObject

Inherited; now it is from a new class, TBaseComponiteteditor inherits. At the same time, TcomponenteditorClass has also changed to TBaseComponenteditor class type, not the class type of Tcomponenteditor. These architectural changes may require you to modify the old Delphi program.

Eight. TDesignWindow changes

Many variations are related to class TDesignWindow. Its declaration is moved to unit designWindows, and the fromClosed method is replaced with DesignerClosed. In the past, the FORM can be accessed by accessing the parameter AFORM in the fromClosed event. In the new event DesignerClosed, we need to access the Form through the Designer root property.

In the FormClosed event, we can create a selection list by calling TDesignersEctionList.create or tComponentList.create. In the DesignerClosed event, you can use the IdesignersElections interface. You can call the CreateSelectronList function to get an interface.

The parameters of the SelectionClosed method are also different from the Delphi 5 versions.

nine. VCL Changes

Some VCL-related packages have been reassigned into other packages. If you quote VCL50.dcp in the project, you need to change this reference to reference vcl.dcp and rtl.dcp.

ten. OpenGL interface unit is changed to RTL.DCP

The Borland OpenGL Interface Unit (OpenGL.DCU) is a separate unit in the library unit directory of Delphi 5. It is merged into the RTL.DCP in Delphi 6. This can lead to some problems when certain Delphi 5 projects are upgraded to Delphi 6.

For example, please. In the project of Delphi 5, you may be able to place the unit as the OpenGL unit in the engineering directory to overwrite the OpenGL unit provided by the system. In Delphi 6, if there is any component reference RTL.DCP, the naming conflict will result in the name of the name. eleven. Some types of declarations in httpapp.pas units are moved to httpprod.pas units

A part of the HTTPAPP unit is moved to the HTTPPROD unit. They are THTMLBGCOLOR, THTMLALIGN and THTMLVALIGN. If you use these classes in your project, you need to change the referenced units from httpprod to httpApp.

twelve. The SEARCH unit is deleted, the SearchBuf routine has made modifications and moved

Unit Search is no longer retained in Delphi 6. The SearchBuf routine is used to locate the substrings in a buffer in a text, which has been moved to the STRUTILS unit, and the parameters called the call also change. The last parameter is changed to a TSTRINGSEarchOptions. If your project cannot be compiled because you can't find the Search unit, change the reference Search to reference the Strutils unit. At the same time, you should check if the call to SearchBuf is in line with the new syntax.

Culture

转载请注明原文地址:https://www.9cbs.com/read-5341.html

New Post(0)