How do I modify Indy 8 IdMessage.pas with Delphi 6? - delphi

I have a copy of Delphi 6 and a simple email program that uses the Indy TIdMessage component. I want to remove lines 464-465 of IdMessage.pas then recompile the application. I'm having a hard time finding clear documentation, so I tried these steps to modify the component:
opened \delphi6\source\indy\indy.dpk in the IDE
double-clicked IdMessage.pas in the Package window
edited IdMessage.pas and saved the file
clicked "Compile" in the Package window
clicked "Build Indy" in the Project menu
clicked "Install" in the Package window
But then I get an error that \bpl\indy60.bpl can't be loaded because \bin\indy60.bpl is already loaded. So I tried "Install packages..." in the Components menu, but only found \bpl\dclindy60.bpl there. So I removed that package, and:
opened \delphi6\source\indy\dclindy.dpk in the IDE
clicked "Compile" in the Package window
clicked "Build dclIndy" in the Project menu
clicked "Install" in the Package window
The IDE confirmed all the components (including TIdMessage) were installed, but the email program is still acting as though the original unmodified component is still being used.
What am I doing wrong?

if you were using runtime packages then you'd need to ensure that your program found the new package file, the .bpl.
But you probably are not using runtime packages. So the runtime program statically links the Indy code using .dcu files located in the Delphi installation folders. Specifically in this case to <ProgramFiles>\Borland\Delphi6\Lib\IdMessage.dcu. You need to make sure you link the new code. The easiest way is to add the modified file to your project. That will mean that the modified version gets compiled and linked into your program.
Since your modifications are in the implementation section of the unit this is all you need to do. If the modifications were in the interface section you'll encounter "Unit X was compiled with a different version of Unit Y" errors. You'd solve that by adding the rest of the Indy source to your project.
One point to stress is that you should never modify the files under the Delphi installation folder. If you want to build modifications to those components, take copies of the files and make modifications in those copies.

Related

Advantech DAQNavi ActiveX Components in Delphi 10.4

Has anyone had any success installing the Advantech DAQNavi components in Delphi 10.3 or 10.4 ?
The big problem is that I cant find a detailed step by step explanation of how to install activex components into Delphi 10.3 or 10.4.
I pay embarcadero for support but their response is "Ask Advantech" !
I have installed the Advantech DAQNavi ActiveX components into Delphi 10.3 and everything appears to go OK without any issues but If I then add them to a form nothing shows on the form. The components appear in the structure list and I can edit them that way, the same applies if I open a project created with an earlier version of Delphi that uses the Advantech ActiveX components.
The fact that something has not worked correctly during the install worries me and I dont feel comfortable compiling projects using these components with this version of Delphi.
Following is a step-by-step guide to installing an ActiveX component for which you have a type library in Delphi Sydney (v.10.04).
Assuming you have a drive D: (I have never trusted Windows with saving important work on its boot drive), create the folder d:\D104, and 2 subfolders below it, d:\D104\Units and d:\D104Pkg.
Start the Delphi IDE if not already running, or do a Close All if it is.
Goto Component | Import Component in the IDE main menu.
Select your type lib from the pop-up
Click Next and set Palette Page to "My Imports"
Click Next and set the radio button to Install to New Package.
Click Next and set the Package name to e.g. D:\d104\Pkg\MyPackage.dpk and fill in the Description box as you think.
Click Finish. The IDE will generate
a file in D:\D104\Units named like MyTypeLib.Pas (but see the comment below step 9) and
the file D:\D104\Pkg\MyPackage.dproj
It will then attempt to compile D:\D104\Pkg\MyPackage.Bpl, which is the package that you need to install in the IDE to have the component(s) in your typelib show up on the MyImports tab of Delphi's Component Palette. Btw, a .Bpl file is a special sort of Dll which, as well as your components, contains some "behind the scenes" code to help .Bpl files get along with one another and the IDE, including memory-sharing.
Assuming the compilation generates no errors, go to Component | Install Packages in the IDE and use the Add button in the pop-up to add D:\D104\Pkg\MyPackage.Bpl and you're done.
If the compile in step 9 doesn't appear to have done anything, it's most likely because the BPL has been generated to the wrong place. Find it and delete it (because otherwise it will come back to haunt you), then:
Open D:\D104\Pkg\MyPackage.dproj as a project in the IDE, then from the IDE's main menu, click Project ! Project Options & on the Project pop-up, select the
"Delphi Compiler" tab, and on the right, set the package Output Directory to D:\D104\Pkg
and click Save, then re-compile the project and use Component | Install Packages to install the .Bpl file.
=================================
Fwiw, in the D5/D6/D7 era, adding components to the IDE was much simpler (and IME less error-prone) because you could do the entire process using a stand-alone Package Editor.\Units
Embarcadero have now looked into it and responded :
"It is bug... it was a fix, for another bug this is one of those good intentions paving fixes."
Apparently the bug simply prevents the control appearing on the form at design time and does not affect the operation of the OCX.

Upgraded Custom Component won't compile

We're currently looking at upgrading some of our Delphi applications from XE7 to 10.3 and have run into a problem with our custom components.
I've tried 2 options.
I've copied, opened in 10.3, and re-compiled the original component package.
I've created a new package in 10.3, added a copy of the relevant .pas files, and compiled a new .bpl/.dpk file.
In both cases, I get a package that I can install into the IDE, and which allows me to add the component into a new project.
However, in both cases, I get "Can't resolve unit name "NewComponent"" in the IDE, and "Unit "NewComponent" not found" when I try and use the component in the project.
I remember this being an issue on previous Delphi updgrades, but have forgotten the trick to fix it.
For my own packages, I have a separate Lib folder \[delphi]\Lib2, then I set the BPL Output Directory in the IDE to that folder, add it to the IDE's Search Path and the OS Path.
That's all I find is necessary and it works fine.

What Is a .vrc file, how is is generated and can you remove it using the IDE?

I am trying to install a commercial component called JamShellBrowser but it will not install.
I have contacted the developer, but meanwhile I'd like to know:
What is a vrc file?
How is it produced?
Can it be controlled or modified with the Delphi XE4 IDE?
I checked the IDE's help but I could not find anything about vrc files and I searched for Delphi vrc and did not find anything that would help me.
The error message is:
Checking project dependencies...
Compiling JamShellDelphiXE4.dproj (Release, Win32)
brcc32 command line for "JamShellDelphiXE4.vrc"
c:\program files (x86)\embarcadero\rad studio\11.0\bin\cgrc.exe -c65001 JamShellDelphiXE4.vrc -foJamShellDelphiXE4.res
[BRCC32 Error] JamShellDelphiXE4.vrc(2): file not found: JamShellDelphiXE2_Icon.ico
Failed
Elapsed time: 00:00:00.1
I searched the components folders for an ico file, but there is none... thus the message, but even if I remove the line MAINICON ICON "JamShellDelphiXE2_Icon.ico" from the vrc file or even delete the vrc file it is automatically generated when I try to install.
I moved from Delphi 2010 to XE4 a few months ago and noticed the apparently new vrc file but I do not know what it is or how to handle these files.
A .vrc is a temporary file created by Delphi MSBuild process to compile resources files (.res) which will be linked in the final binary output. It is passed to CodeGear Resource Compiler/Binder (cgrc.exe) and deleted after the build process.
It doesn't appear anywhere in .dproj file. This behaviour is from BuildVersionResource target, imported from $(BDS)\Bin\CodeGear.Common.Targets. Look at this file (and at CodeGear.Delphi.Targets) if you want to get a better understanding of build process.
Removing <Icon_MainIcon> tag from .dproj it's not enough, as VERSIONINFO resources can also force the creation of .vrc file (I believe "vrc" stands for "Version Resource", although it is also used for main icon in applications).
In case of packages, Delphi always put version info in packages projects. The "include version information" IDE option is ignored with package projects.
So, if you (like me)
don't rely on Delphi IDE to set application main icon
don't rely on Delphi IDE to set version info resources; and
do manage to include your own resources files for everything
you can disable its creation entirely by setting the SkipResGeneration to true in your msbuild call. E.g.:
msbuild.exe myProject /t:Build /p:Config=Release /p:SkipResGeneration=true
However, this only works for MSBuild-based builds. I don't know how to do the same for builds from Delphi IDE.
Just open your #PROJECT#.dproj in any text editor file and find lines
<Icon_MainIcon>#PROJECT#_Icon.ico</Icon_MainIcon>
and delete them.
You will find one per Build target.
Save the file and you are done.
Edit: The original answer referred to the .dpr file, however note the section to edit is in the .dproj hence I've updated the the answer above to reflect this.
I believe this is a built in IDE behaviour of Delphi XE4 and XE5, possibly caused by an upgrade bug. Generation of VRC files is something that you can not disable except by removing the tags in the dproj file that cause it to be generated.
If there was a way to fix it or remove it, it might involve comparing your dproj file with another dproj file and looking for something that was appropriate only to a .dpr+.dproj Project that somehow got into your .dpk+.dproj project, like <Icon_MainIcon>.
It appears to be an intermediate file that is auto-generated when a .dpr+.dproj project has some version information which must be written out of the .dproj file, and into a temporary location and then compiled and linked into your application as a version info resource. However, I have also seen it get generated for a .dpk+.dproj project, and this mystifies me as well.
It also seems to contain a resource for your default application icon and version information, and packages do not normally have a versioninfo or application icon resource.
What I find to be possibly a BUG is that there is no UI in the Delphi IDE to let you set the Application Icon of a Package. Yet, I sometimes get a .VRC and an .ICO file. But I am not aware of a fix, other than to report the issue to Embarcadero Quality Central.
With a .dproj project, a .VRC intermediate file makes at least some sense. I see the following content: Version Info, Application Icon, and VCL Styles (ie AquaLightSlate.vsf) resource linkage.
this is a clarification...
I've just started to install several component libraries into Delphi RAD Studio XE5 that I've got installed in XE2 and XE4. When I try to Build most of them, I get this same error.
The problem isn't so much the .vrc file itself, it's this particular error:
[BRCC32 Error] <project_name>.vrc(2): file not found: <project_name>_Icon.ico
I can't figure out a way to bypass it, and I have no idea what it's looking for or where.
I tend to copy my component libs from one version to the next, opening them, building them, and installing them (ie. the ones that don't come with installers). I've never seen this happen in prior versions. However, this is the first time I've had RAD Studio installed; in the past I've just had Delphi. So perhaps it has something to do with having C++ installed as well?
I had to change my X.optset file to get this to work.
X being the name of your Delphi version you brought over these options from. Mine was PolyDelphiXE2.optset.
Once I corrected the name here no more funny compiling that brought in a different ico reference.

Error Loading a Form

I am a .Net programmer and I'm currently debugging a Delphi application and as I go along
I encountered the following error:
Could you explain to me what is this error, and how I can resolve it?
I am new to using Delphi.
Error Explanation
The error that is been presented to you is telling you that a component on that form is not registered in the IDE, in this case TsStatusBar which is from the AlphaControls library: http://www.alphaskins.com/
The form would have been saved at some point with TsStatusBar placed on the form. When any component is added onto a form they leave references to the component in both the forms source file (*.pas) and the inside the forms dfm. This is why you are getting this error, because the component cannot be found, yet the references linking to it still remain.
Option 1 - Install the AlphaControls packge
The best option would be to install the components that are missing, this will solve your error problem as shown in your question.
Option 2 - Convert Project
AlphaControls provides a tool to convert a project from standard VCL to AlphaControls and vice versa, this may be an easier option then installing the AlphaControls package or manually editing source files, the convert tool is free. Just remember to make a backup before converting should anything go wrong.
Option 3 - Manually Editing the Source Files
You could manually remove these references yourself. Do note though, if you remove the references then Delphi will no longer know that the TsStatusBar was ever there, and without a doubt there will be code somewhere that would have interacted with this component which will create compiler errors.
As an alternative to removing the references, you could rename them from TsStatusBar to TStatusBar, which is a standard statusbar from the VCL. At worst there may be some small syntax errors that may need correcting. If you do decide to edit the forms source and dfm files then I would suggest you do it before loading the form into the IDE.
Option 4 - GExperts
You can also install an IDE Expert such as GExperts which can automate the process of renaming/converting component references.
I would however advise against removing or renaming the references in this circumstance as it seems the project is reliant on the AlphaControls package.
Summary
I can see there are more components from the AlphaControls package been used, so fixing the TsStatusBar error manually will only fix part of the problem.
If the project must remain in its current state then Installing the AlphaControls package is the way to go, if you are able to edit it then I would also suggest the project convert option, this way you won't even need the AlphaControls package.
If you do chose to install the package, it is important to realise that once you install the package Delphi knows where the source files are to be able to compile. After installing the packages, goto Menu > Tools > Options from the IDE, then you need to go to Library and add the folder for the AlphaControls source to the library path. The source folder will be the one containing the most .pas files, but you could add all folders if you are unsure. If you don't add to the Library path then Delphi will not be able compile when using the new components.
Your IDE does not have the package which contains TsStatusBar installed. Find that package, build it, and install it.
Design time components need their code to be integrated into the IDE. This is done using what are called packages. The package project has extension .dpk. You should find this package project in your revision control system. Load the .dpk file in Delphi, click Build from the package manager, and finally, when built, click Install. Now that the package with your component is known to the IDE, your form will load. Whoever maintains this code in your organisation will be able to help with all the details.

Why Delphi says "Unit xxx compiled with a different version of yyy" if all my paths are correct?

First of all I would like to apologize for the question itself. I simply could not make anything better. Well, the question then follows with examples and detailed ...
I manually installed QuickReport Delphi 2006 from their sources. It is composed of two packages a "DesignTime" and a "RunTime".
My Delphi is configured to build the BPL files in "D:\BPL" and DCP files on "D:\DCP" for all packages compiled on my Delphi
The source code of QuickReport are in "D:\QuickReport" and their packages (design and runtime) are configured to save the compiled units (DCU) in the folder "D:\QuickReport\DCU." This was the only configuration done in the packages. Nothing is set up with different paths and, BPL and DCP files are placed correctly in the folders I've set up, as I mentioned earlier.
With these settings I was able to build and install QuickReport without problems (just a few compiler warnings, which I believe are normal). All QuickReport components appear in your palette in Delphi, which does not emit any error on start proving that the components are properly installed and all packages were found.
Now comes the test: I started a new win32 application, completely empty, just a blank form. Then it put a QuickReport component (TQuickRep). The first thing I noticed was that the unit "QuickRpt", which is automatically placed in the clause "uses" of the "interface" is underlined in red indicating that something is wrong.
When I perform a CTRL+ENTER in "QuickRpt" unit (uses clause), the Delphi finds the source file (.pas) correctly, which is in "D:\QuickReport" then I ran a BUILD ALL command and the following compilation error appeared:
[Pascal Fatal Error] Unit1.pas (7): F2051 Unit QuickRpt was compiled with a different version of QRExpr.TQREvElement
That's it!!!
This error is only happening with Quick Report. I have other third-party components installed using the same configuration as the paths and they all work properly.
Finally I was able to solve this problem. #RRUZ and another friend gave me the tip: An lost QuickRpt.dcu file on my system. There were a QuickRpt.res file also. I found them, but the place was very improbable to me: The delphi LIB folder!!!
Well, i have some clues about this bizarre thing.
Until Delphi 7, the QuickReport was shipped together with the IDE however, it was disabled by default. On that Delphi version, all we need to do is to register the bpl to gain full access to QuickReport!
On Delphi 2006, the QuickReport is not part of IDE and there are no BPL to register, however the guys at Borland forgotten to remove all files from the old QuickReport. The Delphi Lib Folder is one of the first folders to be checked on Delphi start, so, if there are old files there, new files on another place would be never compiled, generating the annoying error!
This problem may be present on Delphi 2005 too.

Resources