I have a codebase that I'm working on that is written to work in both Delphi 5 and Delphi 10.2, until we get everything converted to D10.
Whenever I open a DFM file in 10.2 and save it, it automatically adds a DesignSize property to the TForm. This property doesn't exist in D5, so I get errors every time I open the same DFM in D5.
Is there any way to prevent D10 from auto-updating the DFM? Or is this not possible?
You could clear them out using a utility when needed. The JVCL includes a utility called DFM Cleaner that does this. In ends up in $(JVCL)\DevTools after JVCL is installed.
DFMCleaner is a tool to remove unsupported properties from DFMs. If
you save a dfm file in one version of Delphi and want to use it in an
earlier version, chances are there are some unsupported properties in
it, generating an error when the form is opened in Delphi. What's even
worse, if the dfm is part of a design-time package, Delphi will
install the package without errors but when you try to access the form
at design-time (f ex if the form is used by a property editor), Delphi
generates an AV instead.
Related
I'm writing a Delphi package, which provides a new custom TGraphic object, allowing to read a new image format in VCL components like TImage.
I originally developed this package with RAD Studio XE7, and it worked well. However I migrated recently to a newer RAD Studio compiler version, and although my package continues to work properly on that new version, I noticed a strange bug that never appeared before.
I have a form with several components, some of them are TImage components. Immediately after opening the IDE, the first time I open my project in design time, all the TImage components containing my custom TGraphic component loose their content. If I close then reopen the project, the images reappear, and the bug no longer happen until I close and reopen my IDE.
I dug in my code to understand what may cause the issue. To register my custom TGraphic component, I use the class initialization section, in which I wrote the following code:
initialization
begin
Vcl.Graphics.TPicture.RegisterFileFormat('svg', 'Scalable Vector Graphics', TWSVGGraphic);
end;
However I found that, since the XE8 compiler version, the TImage constructor is called before my initialization section, causing thus apparently the above mentioned issue. All the compiler versions since XE8 are affected, but this bug never happened on XE7 or earlier. So something changed since XE8.
Here are my questions:
Is the way I use for register my custom graphic class correct?
If not, what is the correct way to do that?
As something seems different since XE8, what it the new correct manner to register my graphic component?
Did anyone else faced the same issue? How he resolved it?
Is this may be a new RAD Studio bug, or the issue is rather on my side?
This is most likely a side effect of the smart loading the IDE applies to design time packages. You can overwrite this behavior by calling ForceDemandLoadState(dlDisable) during the Register procedure of your package.
More about this can be found in the documentation of more recent versions of Delphi than XE8: Explicitly disabling smart loading of components in a design-time package
Every time I run the .dproj file in xe5, I get an error "Exception EReadError in module StartCoatPro.exe at 000C0304. Error reading LineSeries1.Legend.Visible: Property Legend.Visible does not exist."
I tried looking for the Legend.Visible property under LineSeries1 in the .dfm file but I couldn't find it. Then I also tried to put a line, Legend.Visible = True, but doesn't seem to work too. Please help.
Thanks!
Project files are version-specific. You cannot edit an XE6 project in the XE5 IDE and vice versa, for instance.
But what you are experiencing is not a project problem, it is a DFM problem. You have an XE6 DFM that contains a value for a property that apparently does not exist in XE5. Do not try to edit DFM files across version boundaries, either. Newer versions tend to store new properties that cause errors in earlier versions.
Cross-version project management is tricky. Best not to share version-specific files at all, unless you use third-party tools to help you. For instance, there are tools available that manipulate DFMs to strip out newer properties when downgrading to an older IDE.
While opening a dfm file by double clicking, I am getting following error:
Class TMyClass not found. Ignore the error and continue? Note: Ignoring the error may cause components to be deleted or property values to be lost.
When I click Cancel, I get following message
Error creating form: Class TMyClass not found.
When I click OK now, pas file is opened only.
In pas file MyClass unit is added (which conatins the TMyClass defination) and its path is also added in my search path (Ctrl clicking on unit name, takes me to the unit file)
Everything is fine as per me. I don't know why I am getting this error and why am I not able to open this dfm file in RAD studio? Please help.
To create the component (that you placed on the form) Delphi IDE should know it by name and have its class loaded into memory. That means - it should have that component compiled into binary runtime package and that corresponding design-time package should be loaded into IDE and during the loading it should call RegisterComponent.
Usually this all is done during the library installation. So if you have that library for Delphi 7 now just install it for Delphi XE4 as well.
If your library does not have installer or that installer does not know XE4, then you have to register those components manually, just like Delphi documentations asks you to do.
That is a multi-step process, so you maybe would need to re-do it from starters. However with any luck you would probably be able to reuse the work already done for Delphi 7. At best case you only would have to recompile runtime and designtime packages in XE4 and then install those design-time ones into newer IDE.
http://www.cryer.co.uk/brian/delphi/error_class_not_found.htm
How to install a component from .pas file in delphi?
Delphi XE2: Encounter "Error Reading Form" when opening a project in IDE
Delphi XE4 "class not found" but compiles fine
http://docwiki.embarcadero.com/RADStudio/Rio/en/Installing_Component_Packages
http://delphi.about.com/library/howto/htinstallcomponent.htm
http://delphi.about.com/od/vclusing/ht/installwin32.htm
This problem occurred to me after a new version of Windows 10;
I adjusted by changing the permissions of my executable. I just removed the notification permissions and added it again;
https://support.microsoft.com/en-us/windows/change-notification-settings-in-windows-10-ddcbbcd4-0a02-f6e4-fe14-6766d850f294 for more details;
For me, this error happen when a visual control was declared as TSomething in the pas file and as TSomethingElse in the DFM file.
The solution was to manually edit the DFM file and put the control declaration to the correct value (TSomething).
I'm trying to add a new property (Images: TImageList) to the TMS Control "TAdvSmoothDock" but the property doesn't appear in the Object Inspector
I defined it under "Published" as following :
Published
property Images: TImageList read GetImages write SetImages;
I can compile it but the property doesn't appear in the Object Inspector.
it does appear in the delphi IDE when using the control in the code:
like :
AdvSmoothDock1.Images := ImageList1;
currently I'm using Delphi XE2 VCL.
Regards.
You need to rebuild the TMS packages that contain the component, not just change the source code.
The Object Inspector doesn't use the code source to figure out what to display. It uses RTTI (run-time type information) it gets from the compiled version in the runtime package that contains the component (or the designtime package if there is no runtime package available.
Figure out what package the TMS component is in, open that package's source in the IDE (the .dproj file for the package), and do a build of that package. Make sure it's seeing your version of the source instead of the normal TMS version, so your changes are used.
(Of course, the proper way to do this would be to create your own descendant of the TAdvSmoothDock, add the property, put it into your own package that uses the TMS one, and never touch the TMS source code.)
I have a Delphi project in 2007 that doesn't show the procedure names in the Object Inspector's Events such as Form OnClose, OnCreate or OnShow in the IDE. The code is there and if you click on OnCreate (for example) you are taken to the code and the IDE fills in the name of procedure. However on reload, the procedures are missing from the IDE again.
This same project causes various error messages when Delphi closes also, but I am not sure if this is related (no other project developed under this Delphi does but this one is the largest app and uses several 3rd party add-in libraries).
I have moved this app to various Delphi 2007 installations and it reacts the same, so it isn't a corrupt Delphi situation. Is there any way to rebuild or fix a corrupt project like this? Any help would be appreciated.
I would try to remove all the files and keep only the dpr and the pas/dfm files in case it's a corrupted project file.
I would also double check if there is any Form inheritance mess, as I have seen somewhat similar issues with the inherited event handlers. (look at the dfm files directly)
Try delete all the .DCU's, close Delphi, restart Delphi then rebuild your project.
Delphi's IDE takes several liberties with your code without warning you.
In particular : if you have a callback (eg: "TMyForm.FormCreate") linked in the dfm, and the IDE detects that the function's body is empty, when you save your unit, the ide removes the declaration and the implementation before saving your file.
Adding anything (even a simple "//") in the function's body prevents this : try typing some code or some comment in your function before closing your Delphi.
As for errors when Delphi closes, there can be so many reasons.
Do you have any third-party components or experts installed ?
Have you tried installing IDEFixpack for D2007 ?