Delphi 7 strange disappearance of FormCreate event handler in dfm - delphi

I'm using Tortoise SVN with Delphi 7 and I always have to check the dfm before I commit... but I have a Delphi 7 DFM which has somehow lost it's FormCreate and FormShow event handles! I know that moving the form inside the Delphi IDE causes the dfm to be modified (Top, Left.. etc), but I highly doubt that I removed the event handles manually... so I'm wondering if anyone has experienced anything like this before. Please share your experience. Thanks.

It sometimes happens, but do not know why. Mostly when using frames or inherited forms, and opening/changing a subframe/subform without opening the forms that use it. Or something like that... Cannot reproduce it, but weird indeed.

I have used Delphi for many years and it has never happened to me, but if the code is still there you could just double click on the event (FormCreate and FormShow) and they will be assigned again.

I have experienced this when initially sketching out the method and event structure. If I generate event handles, then move on and compile or run the program with an empty event holder, then CodeComplete will remove the empty handler. I have not encountered this problem in situations where the event handler is non-empty.

Related

Does CancelEdit work on TListItem in a TListView in Delphi?

If I try
ListView1.items[0].EditCaption;
it works as expected allowing me to edit the first items caption, however if while editing I try
ListView1.items[0].CancelEdit;
It does not cancel the editing. Is there some concept I'm missing, is it a bug, or is the help wrong?
This seems to be a problem in Delphi 2007 and XE2 (and probably others).
I think this is a problem with the native control, the VCL does as documented (calls ListView_EditLabel(Handle, -1);), but to no effect. According to the documentation of ListView_GetEditControl, sending the list view a WM_CANCELMODE should also work, which it doesn't.
A test here shows the below works,
winapi.windows.SetFocus(ListView1.Handle);
interestingly ListView1.SetFocus doesn't.

Can I find out what, in a 3rd-party VCL component, is causing Delphi IDE to stop responding when I close a project containing that component?

I have a 3rd-party component that causes the Delphi IDE to stop responding (hang) when I try and close a project that has a form containing the problem component in it.
Is there an easy way to track where in the component's code the problem could lie?
Would it be reasonable to say that it is in the destructor of the component?
What steps would be recommended to try and narrow down the cause?
madExcept does not show anything so it does not seem to be an access violation problem.
Thanks for kind assistance.
The same way you'd track down any other problem: Use the debugger.
Start Delphi and open a project. Set the project's "host application" to be Delphi itself. Run the project in the debugger, and another instance of Delphi should appear. In the new instance, reproduce the bug. When it hangs, go to the debugger (the first Delphi instance) and pause execution. Look at the call stack and find the bug.

FireMonkey iOS TButton OnKeyUp event fails

I noticed that the OnKeyUp event processing does happen for a TButton control when running my iOS application on my iPhone and my iPad (but I believe it does on the Windows emulator). The OnKeyDown event however seems to operate correctly. This looks like a bug to me, but I am not sure.
I have installed service pack 1 on my Delphi XE2 install and recompiled - same result.
You probably mean it does not happen. I experience the same thing, so I cannot say it's a bug or a 'feature' but I at least I can offer confirmation.
I changed my code to react on OnKeyDown instead of OnKeyUp, which is a pain because for edit fields for example the text property is only filled after your code is fired - basically you are always one character 'late'.

Is there a Delphi option to 'lock' the design (layout) of a form against accidental changes?

After years of Delphi development I now have hundreds of forms shared throughout our Applications. Compilation ranges from Delphi 7 through to XE, thus one form might be opened in any IDE. The well-known Explicitxxx property addition after Delphi 7 has solutions to avoid a form accidentally acquiring properties that earlier compilers can't process (e.g Andreas's DDevExtensions) but I'd like a more positive 'switch' that prevented Delphi from making or saving any form modifications at all. Period.
Of course you could use the read-only flag, and a version control system provides additional means particulay of seeing that such a modification has occured. What I'd really like though is a {$LockDFM} switch that I could put in the form's unit, or a context menu option when viewing the form layout.
Can anyone think of a neat way of achieving this?
Thanks
The only thing I can think of (other than the read-only/VCS options you mentioned) is the Edit menu's Lock Controls option. This sets a flag that prevents controls from being moved around. I'm not sure how much good it would actually do, as I've never tried it; I just know it's there.
Helo
I am pretty sure that Delphi has no such a thing. I have been searching for a solution to this problem as well.
But, theres one thing you can do: You can write your own Delphi addon using OTA (Open Tools API). I know that there are a few classes which are able to notify you when something are about to be saved. You can intercept this event and decide if you wanna save it (in your case, if it is a DFM).
BTW, if you have plans to do such component, tell me. :)
EDIT:
I have found a piece of code that may help you. Extracted from http://www.gexperts.org/otafaq.html
TMyFormNotifier = class(TNotifierObject, IOTANotifier, IOTAFormNotifier)
protected
procedure FormActivated;
procedure FormSaving;
procedure ComponentRenamed(ComponentHandle: TOTAHandle; const OldName, NewName: string);
end;
In design time there is Edit->Lock Control.
LE: this is only for resizing/repositioning the controls on the forms. Concerning the ObjectInspector I don't know if there is anything that can 'lock' the values set there(so the developer can not change them).
Basically, no. Aside from the f'ing (pardon my french) explicit size and position properties which IMO never should have been in the .dfm, there are some third party components will change stuff just by you viewing the form. F.x. TMS components will update a version number even if you didn't change a thing since the previous version of their components.

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 ?

Resources