I'm working on a project like that; New units are named consistently after strict rules so we can easily locate the relevant unit. Old units are named after whatever the developer had time to type (and apparently he was always in a rush).
So I introduced a "magic" key that when pressed at run-time displays the name of the active form/frame. It's basically just a TApplicationEvents.OnShortCut on the main form:
procedure TFormAnynymizedToProtectTheGuilty.ApplicationEventsShortCut(var Message: TWMKey; var Handled: Boolean);
begin
{$ifdef DEBUG}
if (Menus.ShortCutFromMessage(Message) = ShortCut(VK_F1, [ssAlt])) then
begin
if (Screen.ActiveCustomForm <> nil) then
begin
var Msg := '';
// Find frames in the form
var Control := Screen.ActiveControl;
while (Control <> nil) and (Control <> Screen.ActiveCustomForm) do
begin
if (Control is TFrame) then
Msg := Msg + Format('Embedded frame: %s in %s.pas', [Control.ClassName, Control.UnitName]) + #13
else
if (Control is TForm) then
Msg := Msg + Format('Embedded form: %s in %s.pas', [Control.ClassName, Control.UnitName]) + #13;
Control := Control.Parent;
end;
Msg := Msg + Format('Active form: %s in %s.pas', [Screen.ActiveCustomForm.ClassName, Screen.ActiveCustomForm.UnitName]);
TaskMessageDlg('YOU ARE IN A MAZE OF TWISTY LITTLE PASSAGES, ALL ALIKE.', Msg, mtInformation, [mbOK], 0);
end;
Handled := True;
end;
{$endif DEBUG}
end;