I am new to delphi 7, I installed TntControls into delphi7, and replace TForm to TTntForm, code like below:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TntStdCtrls;
type
TForm1 = class(TTntForm)
private
{ Private declarations }
public
{ Public declarations }
end;
But when I compile, the error throw:
Undeclared identifier: 'TTntForm'
As people told you in comments, you have to add TntForms into the uses section. The source code is publicly available on GitHub.
In case you still have the same error, be sure that the path to the TntForms.pas is added to Tools > Environment Options > Library > Library Path or at least under Project > Options > Directories/Conditionals.
Related
I manage a huge project in Delphi 2007. The target is to upgrade it to Delphi 10.1 Berlin this year. So in the meantime the source is compiled in both versions.
If there is a problem with the new Delphi we want the old version as backup.
My problem in unit dmActions.pas that is a unit inherited from TDataModule.
uses
// VCL
ActnList,
ActnMan,
Classes,
Controls,
Forms,
Graphics,
ImgList,
Menus,
SysUtils,
XPStyleActnCtrls,
Variants,
{$IFDEF BOLD_DELPHI16_OR_LATER}
System.ImageList,
System.Actions,
{$ENDIF}
BusinessClasses;
Delphi IDE don't understand my IFDEF so it automatically insert missing units to this
uses
// VCL
ActnList,
ActnMan,
Classes,
Controls,
Forms,
Graphics,
ImgList,
Menus,
SysUtils,
XPStyleActnCtrls,
Variants,
{$IFDEF BOLD_DELPHI16_OR_LATER}
System.ImageList,
System.Actions,
{$ENDIF}
BusinessClasses, System.ImageList, System.Actions;
But this don't compile in Berlin with this message
[dcc32 Error] dmActions.pas(36): E2004 Identifier redeclared: 'System.ImageList'
[dcc32 Error] dmActions.pas(36): E2004 Identifier redeclared: 'System.Actions'
And of course "System.ImageList, System.Actions" don't compile in D2007.
So what is my best action to solve this ?
You can make use of the Unit Aliases feature of Delphi here - at least as your Delphi 2007 supports dotted unit names in the first place. This allows to use the new unit names like System.SysUtils from Delphi 10.1 Berlin and still compile that project with Delphi 2007.
For this you have to add mappings to the Unit Aliases of the Delphi 2007 project like this:
System.SysUtils=SysUtils
System.Classes=Classes
For units that don't exist in Delphi 2007, like the ones you mention in your post, simply map to an existing unit:
System.Actions=ActnList
System.ImageList=ImgList
As a benefit you end up with uses clauses free of IFDEFs.
As https://stackoverflow.com/users/2916756/nolaspeaker said it works by test compiler version directly. I used an inc-file and that don't work well in this case
But in my case I check Berlin so:
{$IFDEF VER310}
System.ImageList,
System.Actions,
{$ENDIF}
I'm testing on Delphi 2007 and my groupproject is composed by 2 packages.
PackageRun.bpl
It's marked as "runtime only" and contains a unit named "uMyTestRun.pas" in which is defined an empty TFrame descendant:
unit uMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
PackageDes.bpl
It requires PackageRun.bpl, it's marked as "designtime only" and contains a unit named "uMyTestDes.pas" in which I wrote the following code:
unit uMyTestDes;
interface
uses
Classes,
uMyTestRun;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Output directories of both packages are in Library paths (Inside there are bpl, dcp and dcu).
Trying to install PackageDes.bpl (Component, Install Packages..., Add...), I'm getting the following error:
Can't load package C:\<...>\PackageDes.bpl. Impossibile trovare il
modulo specificato.
The last part of the message is in my OS's language, in english it should be something like "Can't find specified module". (My OS is Windows 10 Pro 64bit).
PackageDes.bpl is exactly in the same path shown in the error message (C:\<...>\PackageDes.bpl).
After some tests, I found that the error disappear by removing the following line from uMyTestDes.pas unit:
RegisterComponents('MyComponents', [TMyTest]);
Is there something wrong in my code/projects/environment?
Run Process Monitor from http://SysInternals.com and set the filters to intercept only file operations ( toolbar rightmost buttons ) of your Delphi IDE process (check the process name in TaskManager or shortcut properties (it is bds.exe for Delphi XE2), then add the filter similar to Include / Process Name / Ends With / bds.exe ).
Then clear the log in PM, switch to Delphi and try to load the package, then as soon as error pops up switch back to PM and stop capturing events. Try to do it fast as you can, for example do not waste your time closing error box.
Now you would get a trace of file I/O activity of Delphi loading the package of yours (and some other background activity noise - the faster you do the less noise there'd be). In that trace look for all the errors and see where and which package Delphi tries to find.
You can also try Microsoft Dependency Walker or similar tools to se if your Design-Time BPL has all the DLL-dependency tree resolvable. Personally I usually use Unreal/Total commander with FileInfo plugin or ntCore CFF Explorer.
Easy way to solve this issue is to add a post build action to your run time project:
copy "$(OUTPUTDIR)\$(OUTPUTFILENAME)" "$(BDSCOMMONDIR)\Bpl"
The command above copies your run time file to the default IDE Bpl location.
I had a similar issue. In my case I had the same library name in a different Delphi version BPL path. I found out the solution for my issue looking at the comments above, so this is only a reminder for basic things to check:
BPL path have to be included in your OS path variable;
Search for a BPL module with the same name in other OS path before the right one (mutiple Delphi version installations).
Try to change the register procedure to uMyTestRun unit.
unit UMyTestRun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
type
TMyTest = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyTest]);
end;
end.
Now, the package will install correctly.
Regards.
i have a problem compiling my Delphi code.
I have 3 classes, XmlFileManager (concrete), XmlNodeManager (abstract), XmlEnpManager (child of XmlNodeManager and concrete).
Below, a little of definition class code:
XmlFileManager
unit XmlFileManager;
interface
uses
xmldom, XMLIntf, msxmldom, XMLDoc, SysUtils, DateUtils, Classes, Dialogs,
XmlNodeManager, XmlEnpManager;
type
TXmlFileManager = class
[...]
end;
[...]
end.
XmlNodeManager
unit XmlNodeManager;
interface
uses
xmldom, XMLIntf, msxmldom, XMLDoc, SysUtils, DateUtils, Classes, Dialogs,
XmlFileManager;
type
TXmlNodeManager = class
[...]
end;
[...]
end.
XmlEnpManager
unit XmlEnpManager;
interface
uses
xmldom, XMLIntf, msxmldom, XMLDoc, SysUtils, DateUtils, Classes, Dialogs,
XmlFileManager, XmlNodeManager;
type
TXmlEnpManager = class (TXmlNodeManager)
[...]
end;
[...]
end.
In the XmlNodeManager and XmlEnpManager, not recognize TXmlFileManager class. An whe i compile, the compilation fails with message:
[dcc32 Fatal Error] SiGAS.dpr(23): F1026 File not found:
'XmlManager.dcu'
In the past, the XmlFileManager was called XmlManager.
Any ideas ?.
My .dpr:
uses
Forms,
Main in 'forms\Main.pas' {Principal},
Globals in 'units\Globals.pas',
CrearProyectoForm in 'forms\CrearProyectoForm.pas' {NuevoProyecto},
Validadores in 'units\Validadores.pas',
IdiomaClass in 'units\IdiomaClass.pas',
IdiomaCastellanoClass in 'units\IdiomaCastellanoClass.pas',
ExcelFileManagerClass in 'units\ExcelFileManagerClass.pas',
SeleccionarIdioma in 'forms\SeleccionarIdioma.pas' {SelectLang},
EnpView in 'forms\EnpView.pas' {ENP},
EnpViewGeneric in 'forms\EnpViewGeneric.pas' {EnpGeneric},
Vcl.Themes,
Vcl.Styles,
EnpViewAdd in 'forms\EnpViewAdd.pas' {EnpAdd},
EnpViewAddAfter in 'forms\EnpViewAddAfter.pas' {EnpAddAfter},
EnpViewEdit in 'forms\EnpViewEdit.pas' {EnpEdit},
EnpInicial in 'forms\EnpInicial.pas' {ENPViewInicial},
XmlFileManager in 'units\XmlFileManager.pas',
XmlNodeManager in 'units\XmlNodeManager.pas',
XmlEnpManager in 'units\XmlEnpManager.pas';
Your main source file, SiGAS.dpr, still has it listed as XmlManager, so...
Open your *.dpr file (it is just Delphi code) and fix the unit name in the uses clause, then rebuild.
I have registered the package TMS Unicode Component Pack in my Delphi 7 containing TNT components.
This package contains a class named TTntCustomComboBox which I use to create my own custom component named Combobox2 :
unit Combobox2;
interface
uses
Windows, Messages, Classes, Graphics, Controls, StdCtrls, ImgList, ActiveX, SysUtils, TntStdCtrls, TntWindows;
type
TCombobox2 = class(TTntCustomComboBox)
...
procedure Register;
begin
RegisterComponents('Standard', [TCombobox2]);
end;
...
I've added this component (TCombobox2) to the package dclusr.dpk.
Compiling dclusr.dpk works but installing the package raises an exception :
Registration procedure Combobox2.Register in package C:\program files\Delphi7\Projects\Bpl\dclusr.bpl raised an exception class EFilererror : A class named TTntCustomComboBox already exists
So, how do I fix that ?
Thanks for help.
The error message indicates that your package is trying to register a component that is already registered, namely TTntCustomComboBox.
It's not obvious from the details that you have provided why this would happen. One possible reason would be if you included the TNT components in your package instead of referencing that in your package's requires clause. Another possible reason would be if your Register function attempted to register TTntCustomComboBox. This could happen if your actual declaration of TCombobox2 was like so:
TCombobox2 = TTntCustomComboBox;
Put {$WEAKPACKAGEUNIT ON} after unit caption.
First of all, sorry for my bad english.
I started with Delphi today, created a simple form example named test.
unit teste;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
end.
I searched at google, then here and did not find an answer for this problem, I´m not able to run it, because the logs return these errors:
[ILINK32 Error] Fatal: Unable to open file 'STDCTRLS.OBJ'
I had no idea how to fix it, could you help me?
Thanks!
best regard´s.
It looks like you've created a C++Builder project, but written/pasted in Delphi code. Delphi doesn't use ILINK at all, and it doesn't use STDCTRLS.OBJ (it would complain about StdCtrls.dcu instead).
Since you have no functional code in the project, I'd just start over. Use File|Close All, and don't save changes. Then use File|New|VCL Forms Application - Delphi for Win32, and hit F9 to see if you can run that project.
Make sure the IDE's search paths are configured correctly, and that the project has correct references to the RTL and VCL packages.