TFrame as Component, IDE changes object to inline on first use - delphi

I have created a Tframe unit with visual and DB controls. I registered the frame as a component using the sprig approach. The TFrame has a few published boolean properties.
Everything works OK, except I have noticed that if I start the IDE and open a project that uses that component, the IDE complains about the "unknown" published properties. And if one looks at the DFM, Delphi has changed the definition for the frame within the form it is embedded in from "object ..." to "inline ...". If I just close the project, without saving, and re-open it, all is good.
It only happens on the first project open.
Any suggestions would be appreciated.

The thing here is that registering a TFrame does work, but publishing properties almost always does not. I say "almost always" as i had this kind of issue in the past (Delphi XE2 as far as i remember) and there seems to be a bug in the designer deeply hidden somewhere. Debugging this issue gave me no results back then.
I suggest you simply move the published properties to public and set these properties in source code directly. This is a workaround but it works.

Related

Delphi .exe after build error

good day! i have a project and it runs perfectly, i did that project 3 months ago. Then, i tried to put some changes and even BUILD ONLY the project (no additional codes). When i open the .EXE it appears errors like this.
when i clicked DON'T SEND
and when i clicked OK
When i opened the form this message appers:
How to fixed it? I really need to add some functions to that project.
Thanks in advance!
Your .dfm file refers to a property that is not published by the component which is being streamed. The streaming framework is attempting to read into a property named Quality of an object named frxPDFExport1. And that object does not publish a property of that name.
Most likely there's a mismatch between the design time package that you used to generate the .dfm file, and the run time component that is reading that .dfm file. Have you upgraded one and not the other recently?
I'm afraid I cannot give you precise steps to fix the problem, but what I describe above is what is happening. Hopefully that will be enough to lead you to the solution.
You must have updated the component used, which looks like Fast Reports. You need to open up the form in Delphi and the new property will be added by Delphi. Any other forms that use the same component will also need to be opened up to update the properties.
When the error reading form message comes up, click ignore. This should add the missing property. You will want to view the DFM as text to make sure the property has been added.

THotKey does not work anymore under Delphi XE

I have upgraded an old project from Delphi 7 to Delphi XE.
The project has (among others) some THotKey controls. Under Delphi 7 the THotKey controls are working ok. But under Delphi XE they are like disabled. This means that they show nothing inside even if a shortcut (Alt+A for example) is assigned to them and I cannot edit them.
Anybody else has this issue?
Update:
I deleted ALL controls and all code from that project. Now I have ONLY the main form and a single THotKey control. Basically, after deleting all the controls my project is like a brand new created project without a single line of code. But the THotKey is still not working under Delphi XE and still works under D7.
Cause found (Delphi bug)
I compared my project with a new created project. I have seen that the old form had the 'double buffering' option set while in the new project this was not on, so I manually turned off this option in my old form. Guess what? The THotKey works!!!!!!! Every time I turn the 'double buffering' on, the THotKey goes ape.
Confirmed
Yes (by Andreas Rejbrand)
Solution (partial):
I have seen that it is not actually main form's DoubleBuffered property that causes this but rather THotKey's. So it is enough to turn off this property for THotKey, not for entire form. I think I can leave with that.
:)

Very Weird Behavior: Delphi 5 adding a component on my form with empty name

Now this is a very puzzling matter I hope you can help me.
I have a custom component derived from TCustomControl that is included in a package. This package is correctly compiled and installed in D5. The package also requires the use of another library of components the ImageEn library.
I have an application that uses this component, Now until some day ago everything seemed to be fine, but now, after some recent changes to the component (mostly changing the name of the types it uses) I am having a very weird behavior going on. On the form where this component is placed Delphi will create I would say just for no reason a TImageEnIo component (from the ImageEn library) that was not even included in the dfm of the form.
Even more puzzling is the fact that this added imageenio component has no name, thus causing me a lot of trouble when I try to run the application (run-time error). If I delete this component it will reappear as soon as something is updated (for example if I switch between the text and the form of the dfm). Delphi just adds this thing on any form , where I use my custom component. This happens only when my custom component is present, other comps of the package do not generate this problem.
I noticed that it creates 1 of these empty TImageenio for each custom component I have on the form, and moreover if I switch back and forth between the text and the form views of the dfmit will add another imageenio component each time I do this.
Finally the problem is not dependent from the application as it will happen with any application as long as I add my custom component on a form.
Now I have been recompiling everything the imageen and my package many times, I have even tried to restore an older version of the component but the problem persisted (I am quite sure I hadn't experience it with the older version), I have tried anything conceivable but I cannot figure it out. I am at a complete loss, please advice If you need more info please ask, I will try to explain better.
Many Thanks to those who will take the time to answer.
It would seem that the problem was introduced by recent changes in your custom component.
You should use your revision control system to go back to a known good version. Then advance to intermediate versions of the code, perhaps using a binary search for efficiency. Once you've isolated the revision which introduced the bug then you should be able to study the code changes in that revision and identify the problem.
Wild guess: Your custom component directly or indirectly instantiates a TImageEnIo with the wrong Owner. Instead of using Self (i.e. the custom component instance) it uses its Owner property, which points to the form it is sitting on.
The first thing I would try would be to start a new application, create one of your custom controls at run time and put breakpoints on the third party source code where the TImageEnIo component is instantiated, constructor of the component would be fine. If the design time behavior is exhibited at also run-time, the breakpoint would be hit and you would be able to figure out the code part creating the component from the stack trace.
Otherwise, it is possible to debug design-time behavior by debugging the IDE with another instance of the IDE, but I don't know how it can be done with D5.

One project in Delphi 2007 doesn't show procedure name in the IDE Obj Inspector's Events

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 ?

Delphi - Class TListView not found

We have a Delphi 5 application, that is built without runtime packages, dlls or external resources (i.e. a single executable). when we install it on a clients PC we get the following error messages:
Class TListView not found
or
Class TImage not found
We have installed it on dozens of PCs before without incident, but this latest install is problematic.
The target PC is a fresh install of Windows XP (Service pack 3) with no other software installed.
It does not complain about all of the classes however just one or two. for example TPanel/ TForm/ TEdit are all OK.
Can anyone think what is causing this?
EDIT
The exe on the new PC is on 30 or so other PCs that I know of, ranging from windows XP Sp1,2,3, Windows Vista and Windows embedded. both old and new PCs were installed with an old version and then updated with the newest version. The only difference is that the version jump was higher for the latest install.
This is typically an error during the streaming of a .DFM. Usually this error occurs with TLabel components because many folks remove the TLabel fields from the form or frame in order to cut down on the clutter and reduce the instance size of the form. The common and confusing mistake they make, however, is that in their over-zealousness, they remove all TLabel references. That is when bad things start to happen. Let me run down how the streaming system locates a component's class.
Remember that the class reference in the .DFM is just a string. The streaming system has to convert this string into a class reference (TComponentClass). There are two mechanisms that the streaming system uses to do this. The first one is very simple and involves a global list of class references. You can call RegisterClass or RegisterClasses to explicitly make the streaming system aware of it. The second is much more subtle and not very well known; in fact it is all part of the "magic" of Delphi :-). When the compiler builds the form, all the fields that represent the components on the form are processed and an internal table is built as part of the RTTI or metadata for the form/frame/datamodule itself. This table contains a list of references to all the individual component types represented by the component fields. So even if a component is not in the global list, it can still be found by scanning through this compiler generated table. That is what the Classes.TReader.GetFieldClass() method does.
Back to my TLabel example, this problem is easily fixed by simply ensuring that at least one of a given component type has a field. So as long as there is at least field of type TLabel, all the other TLabels will load just fine. So in your case, make sure the TListView or TImage fields haven't been deleted.
Re0sless,
I suggest you open and close every form of your application and do a fresh build after that. If memory serves me well, that was the solution when we encountered similar problems.
You might also take a look at DFM Check to open and close all your dfm's automatically and at CnPack to help you clean your uses clause.
Regards,
Lieven
I think Lieven is definitely on the right track: simple base classes not being found during runtime are a Delphi (linker) problem. This exception is not caused by the Operating System.
My experience with similar problems: the linker generates a project with the units wrongly arranged.
Example: a form unit is linked in before the base units. Forcing the project to completely recompile/relink itself should make this exception go away.
A simple [Rebuild All] will probably not suffice. You might try to recompile without optimizations.
I have tried to reproduce this error but I have not been able to. The Delphi compiler/linker is one of the best - speed of compilation/speed of compiled exes - but this bug is definitely a show stopper.
Note: I have only experienced
this error in D5. Has anybody else
experienced this error with other
Delphi versions?
I had the same problem. Class TCheckBox not found. I usually edit large set of components through .DFM of form(for example renaming large amount of component). This error comes when I rename all CheckBox on my form through it .DFM.
I just cut all the checkbox and paste them again(So .DFM file is refreshed). The error disappeared.
I've seen a similar problem due to a file copy error. To make matters more confusing, the fault was on an intermediate media device. The issue was resolved by simply recopying the file from the existing release build.
It is probably impossible to confirm now, but it is quite possible that the problem was 'solved'; not because of the removal of an unnecessay uses clause item, but because it also involved a new copy of the executable.
The solution for all errors of this type "Class XXX not found" is simple. Open DFM file of a form in text editor and manualy remove the definition of the XXX object in it.
Change the name of the Form and save the .pas with other name. Change all references to create the new unit name if this is used in other units. Build All.
With this the error disappeared.

Resources