Reputation: 14375
I have a component that is used widely throughout my application code base (i.e. - multiple applications). I want to change one of the commonly used event handler properties. I need a tool/utility that would go through a Delphi 6 form source file (DFM + PAS) and do a search and replace for the currently defined event handlers for instances of the component on the form.
For example. Suppose I have an event handler property on the component currently defined as:
property eventHandler1: TOldEventHandlerProc read FOnEvent write FOnEvent;
Where TOldEventHandlerProc is defined as:
TOldEventHandlerProc = procedure(oneParm: string) of object;
I want to change TOldEventHandlerProc to:
TOldEventHandlerProc = procedure(oneParm: string; twoParm: integer) of object;
I would want the utility to examine the contents of a Form's DFM/PAS file pair and find all instances of FOnEvent that are defined and swap out the old parameter list for the new parameter list, based on the new definition of TOldEventHandlerProc. For example, given a form named MyForm1 with an instance of the component named MyComp1 you would have the following IDE generated declaration for the event handler:
TMyForm1 = class(TForm)
// IDE created event handler stubs.
procedure MyComp1OnEvent(oneParm: string);
with the body of the event handler declared as:
procedure TMyForm1.MYCom1OnEvent(oneParm: string);
The utility would need to find each instance of OnEvent() handler and substitute the header declaration for the event handler and the body declaration for the event handler and swap the parameter lists with the result being:
TMyForm1 = class(TForm)
// IDE created event handler stubs.
procedure MyComp1OnEvent(oneParm: string; twoParm: integer);
with the body of the event handler declared as:
procedure TMyForm1.MYCom1OnEvent(oneParm: string; twoParm: integer);
If I can't find such a tool I'll write a quick and dirty one myself but I figured I'd ask to see if I could save myself some time. Does anyone know of such a refactoring tool?
Upvotes: 2
Views: 377
Reputation: 7575
Refactoring feature is available in recent Delphi version.
You can easily refactor your code using one of them and eventually fix every DFM to ensure Delphi 6 compatibility.
Upvotes: 2