Move selected text to right/left - delphi

How to move selected source text to left or right in Delphi 2007 code editor? I need short key command. Is it possible at all in Delphi 2007? How about other versions? Is it possible to manage this with any additional tools?

You can indent/outdent (unindent) selected text in the Code Editor with the default keymapping using Ctrl+Shift+I (Indent) and Ctrl+Shift+U (Unindent).
(Recent versions of the IDE use Tab and Shift+Tab to do this as well.)
If you're using another key mapping (such as Brief or Visual Studio), you can find a list of the key mappings in the help file under Key Mappings; the individual key assignments are listed there.

Related

Where is the Component Toolbar configuration data stored in Delphi XE4?

I'm trying to customize the appearance of the Component Toolbar pages within Delphi XE4. I clicked on Tools > Options > Component Toolbar
I highlighted Data Access and moved it up underneath Standard and clicked OK. However it still shows up in the IDE Tool Palette in the original location underneath Samples.
Ray Konopka distributes a utility that moves all the Raize components to the top of the list in the Tool Palette so there's got to be a config file somewhere that I can tweek so the pages and components are in the order I'd like them to be.
Where can I find this file?
Looking at Delphi XE, it is stored in the key HKEY_CURRENT_USER\Software\Embarcadero\BDS\8.0\ToolForm\Mapping(Default), so I guess that for Delphi XE4, it will be HKEY_CURRENT_USER\Software\Embarcadero\BDS\11.0\ToolForm\Mapping(Default). To read this key, this answer should help : How to read Default Value of Registry Key

Display the Procedure/Function the cursor is in

Does the IDE display the current Procedure or Function that the cursor is inside of? If I search for myVariable is there any way to know (without having to scroll up) which function I landed inside of?
If it is not native are there any plugins that support this feature?
This functionality is not available in the IDE itself.
The an open-source CNPack Wizards have this functionality. See the images below, particularly the highlighted areas of the toolbar and code editor window. (Image from Delphi 2007 IDE, but CNWizards support later versions of Delphi up to and including XE5.)
It works with code that contains procedural (non-OOP) code as well. Here are two captures of separate procedural functions/procedures, with the relevant portions of the toolbar and code editor highlighted:
Castalia has this feature, among other things.
Since it is not an existing IDE functionality, various 3rd party tool providers have added it to their product.
On the list of existing tools is ModelMaker Code Explorer.
On the list of past tools, I'd like to add CodeRush as it was among the first to implement it. A screenshot can be found here (scroll down a bit).

Modifying old Win32 application without source code (possibly written using Borland tools)

I have a quite old Windows application (1998) which is no longer maintained by the author and I don't have its source code. This application in one of its windows has a dropdown list widget where the user can choose one of the 4 predefined values (numbers). I need to add new predefined values there or change the widget to something that lets me introduce any value (some edit field or editable combobox).
Some other data about the application:
Probably written using some Borland tools, I guess it uses BDE and Paradox as its database.
There is a file with .mme extension in the directory. I unpacked it and it contains 5 files: .data, .rdata, .rsrc, .sdata, .text. I viewed them in a hex editor and they contain some text data but I don't know how to look for those predefined values. Since they are numbers it's probable that I will find just some other numbers.
I tried using RedEdit and XN Resource Editor but they show only the icon and version info.
I know my question is kind of vague, but if I don't find any solution to this I will have to rewrite the whole program, so I'm asking just in case there is a solution.
It might be possible to write another app that looks for this program, gets a handle to the window owning the drop-down box (if t's a native windows component), and then gets a handle to the drop-down box and use the Windows SendMessage API to manipulate the contents of the drop-down box.
http://msdn.microsoft.com/en-us/library/ms632595(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms644950(v=vs.85).aspx
It might require so much effort that it may be better to just rewrite the app!
If it is written with Borland tools, you can probably find out which one by searching the EXE for the string "Borland" - there should be a copyright string somewhere.
Once you know, find someone with Borland tools experience and have her find out if those numbers in the drop-down list happen to come out of a database table. If they do, try modifying that table, if not, rewrite the app :)

How can I interrogate the Delphi component palette?

I have lots of components installed - trouble is when I want to find one I rarely use it takes ages to find it. I can look at the ALL choice which lists all components but finding one with say 'grid' in the title is still very time consuming. Is there a database of titles or (preferably) a text file I could interrogate and search?
Try DDevExtensions 1.61, it add ability to search for components for Delphi from version 5 and above, with other many improvement for the IDE.
Which version of Delphi? In recent versions, just click on the top of the palette and type "grid". Ctrl-Alt-P will focus the palette, and then you can just start typing.
In RAD2009 and RS2010, do this and it'll find all components with "grid" anywhere in the title.
Since you didn't specify which version of Delphi...
1) In older versions (D7 and before), you can right click on the component palette to see the properties. This shows all of the components you have installed one page at a time. It isn't searchable, but at least the list shows each component's name and package, so it's easier than using the popup hints on each individual component.
2) In Delphi 7, you can select View|Component List, which brings up a searchable alphabetical list of all components. Unfortunately, it only matches on the first part of the component name. The first version of the "new" tool palette had this same limitation.
3) DDevExtensions (free) allows partial string matches in the old component palette (D5-D7), and restores something like the old palette in newer versions of Delphi (D2005 and up). It's also included in Delphi 2010 for people who prefer that style. I like how the search works in Delphi 7, but in Delphi 2010, the filtering seems a little awkward to me. It filters the components and palette pages, but if you have matching components on more than one page, they aren't all shown at the same time. You still have to click on each individual page.
4) My favourite. I prefer the new tool palette (Delphi 2005 and up). Very configurable, lets me see the component names, shows components on more than one page at a time, dockable, etc.
Bottom line. If you don't have or don't like the new tool palette, get DDevExtensions.
Before Delphi 2005: Install DDevExtensions, then choose Tools -> DDevExtensions Options -> Component Selector -> Check the "Active" box, click OK
Delphi 2005 and later: Click in the component palette and type the name of the one you want.
Use GExperts - they help a lot.

Best Way to Replace a Visual Component in Delphi

In a Delphi Form, I would like to replace one visual component with another. Example: I want to replace a Panel component with an ElPanel from a 3rd party package.
I would like all identical properties and events of the first component to be transferred to the new one, and all the components that belong to the first component (e.g. Toolbars, memos,status bars, etc.) to end up placed on the new component exactly where they were on the first one.
Is there a best/easiest way to do this other than adding the new component to the form and meticulously transferring every property, event and component to it one-by-one?
I do it as following:
Right click on the form and choose (View as Text).
Press Ctrl + F to search for the Component class name like TPanel and replace it with TElPanel
Switch back to back to the form (View as form)
In the interface section replace the TPanel with TElPanel.
if you have many components using GExperts will be more feasible solutions.
You can use GExperts or you can do it by hand.
To do it by hand, open the .dfm in notepad and replace all the class names. (Replace TPanel with TElPanel for example). When you've made all your changes, open the .pas file with Notepad, and do the same thing.
Make sure you add the required units to your uses clause.
Then open the form in the IDE and clean up any mismatched events or unknown property problems.
If I recall the excellent free GExperts plugin does this. Right click your form and select "Replace Components". http://www.gexperts.org
IMHO, the big drawback of the Replace component GExpert is that it changes the order of the components in the source code. That is not very VCS friendly. :-)
If you have other components inside a container doing this replacement with GExperts will cause some ugly exceptions and possibly unexpected behaviour in the IDE.
So, the best solution is to edit the .dfm file where you want (inside or outside the IDE) and replace manually the types of the components that you want to change. Maybe it will cause some exceptions too, but the IDE will managed them.
If you do it inside the IDE, after switching to design view if you save the .dfm inmediately the IDE will ask you to change the type of the variables related to the components you touched, liberating you to do it.
To convert between text and binary dfm formats, use the convert.exe tool in the Delphi bin\ directory. – Tim Knipe (Oct 28 at 4:15)
You can also use the context menu of the form designer - at least with BDS 2006. It's the last menu item ("Text-DFM" in a German IDE).
In my project I had to convert few doezens forms from one set of components to another.
I have created small perl script to convert components and its properties and do all neccesary mapings.
The script is quick&dirty solution but it is highly configurable. It scanns all dfm and pas files in project direcotory and convert dfm components definitions according to rules that you should provide in ObjectBeginFound, PropertyFound, ObjectEndFound procedures/events.
DFM files should be in text mode. Tested on Delphi 5 files. I don't know if it will be compatible with newer versions. Please send posts if you find it out.
USAGE:
perl.exe cxdfm.pl > logfile.txt
DOWNLOAD LINK
http://dl.dropbox.com/u/15887789/cxdfm.pl

Resources