tags:

views:

214

answers:

3

Is there a way within the Delphi to search within the dfm files for a string?

When I try the Search->Find in Files specifying .dfm it does not work. However, if I change all the extensions from dfm to txt and specify .txt as the extension it works.

+13  A: 

I'm using the GExperts grep and it works very well with dfm when you check "Search Form Files"

alt text

Update: why I prefer GExperts to D2010 "Find In Files"...

  • I work with D2007 as well as D2010. I can use the same search tool consistently in both.
  • You can limit your search to Open/All-in-project/All-in-project-group and still get the dfm, while in D2010 you get the dfm only for directories and it does not even work in D2007.
  • I can use both if I want.
François
GExperts can be downloaded here: http://www.gexperts.org
Robert Love
Delphi 2010's "Find in Files" can do that as well.
Giel
@Giel, but only to search in Directories. (see my edit)
François
So, aside from using GExperts, Delphi 2010 does it but not Delphi 2007 (I should have mentioned I was using D2007)?
M Schenkel
@M Schenkel. Yes, D2010 does it if you explicitly include *.dfm in the search mask, but not D2007.
François
+3  A: 

There is any easy way to work with DFM files.

  • Open the form so you can see it visually.
  • Right-click and select 'View as Text'.
  • Treat the resulting text file as source code, play with strings etc, then when you're done, right-click and select 'View as Form'.

    Try it.

Brian Frost
You can also use ALT-F12 to switch between the form designer (but not the code view) and the form as text.
Mason Wheeler
Yes - I was aware of that. But what I really need to do is to search within all DFM in a directory or set of directories.
M Schenkel
+2  A: 

Ok... Not sure if you meant for a way to search from Delphi's IDE or from Windows. From Delphi's IDE, like François mentionned, GExpert's GREP search does the job. To allow Windows to read DFM/PAS files, you need to add a few registry key to allow it on Windows XP and later. Save the following content in a *.reg file and double-click on it to install in registry. (Note, that works in WinXP. I didn't try it in Win7/Vista)

Some of those keys might not be required... I just copied stuff from the [HKEY_CLASSES_ROOT\.txt] key. ^_^

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.dfm]
"PerceivedType"="text"
"Content Type"="text/plain"

[HKEY_CLASSES_ROOT\.dfm\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\.pas]
"PerceivedType"="text"
"Content Type"="text/plain"

[HKEY_CLASSES_ROOT\.pas\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
Ken Bourassa
Thanks for the detailed response. Yes - I meant to say "Within the Delphi IDE".
M Schenkel