Generating a new Random GUID in the Delphi IDE - delphi

How I can generate a random new GUID inside of the Dephi IDE?
I am using Delphi 2007.

Just press Ctrl + Shift + G

Ctrl+Shift+G will place a new GUID at the current position in the editor.
It's formatted for use as an interface IID, i.e. with enclosing square brackets - [] - , but once you've got the GUID in the text editor you can do whatever you want with it - Copy/Cut it to the clipboard etc

I had wondered why this didn't work for me, but now I found out that it depends on the selected keyboard-layout in the Delphi-Options (Options->Editor-Options->Keyboard).
With the classic IDE layout it really is Ctrl+Shift+G, but I usually use the VisualStudio-Emulation and there it is Ctrl+Alt+G instead.

Default key shortcut for Get module in Jedi VCS (if anyone still use VCS today) is the same and must be cleared in Jedi VCS Settings. Otherwise GUID shortcut won't work.

Related

How to start search from the caret position instead of the beginning of the file in IDE?

I am using Delphi XE5 but this was in Delphi XE2 too. I don't know what I did but when I use CTRL + F, type keyword and hit Enter, it starts to search from the beginning, not from the current caret pos. Does anyone know a solution to this, please ?
According to the documentation, this option in XE5 is now named Entire Scope:
http://docwiki.embarcadero.com/RADStudio/XE5/en/Find

GExpert's Replace Components Expert doesn't replace the text in the form file (*.dfm)

I am using Delphi 2010 and GExperts stable release 1.35
I am testing the "Replace Components" expert.
I add a main form and a secondary form. Each has three TEdits on it.
I use the Replace Components Expert to replace all TEdits with TRzEdit. I Check the Replace all components on all forms of the project.
It works, it replaces them all. However, it doesn't do anything to the DFM file. How do i make it replace those instances.
If i save, compile, or rebuild, i get errors.
If i try to view the form as text after replacing, i get errors.
Can someone explain to me the steps to make this work?
Thanks
I just tried it with Delphi XE and GExperts 1.35 and it does indeed crash now even after a single "Replace Selected". (It used to work fine in the past).
It seems that using the hidden menu Project | Clear Unit Cache just after Replace Components then doing a full build before trying any Save/Compile/View As Text... fixes the problem.
I think this menu is surfaced with cnPack. I don't have it and cannot guarantee, but you can easily do it yourself by adding the following unit in one of your installed packages:
unit FGEnableHiddenMenus;
interface
procedure Register;
implementation
uses
Classes, Forms, Menus;
procedure Register;
var
Comp: TComponent;
begin
//Make a hidden menu item visible
Comp := Application.MainForm.FindComponent('ProjectClearUnitCacheItem');
if Comp is TMenuItem then
TMenuItem(Comp).Visible := True;
end;
end.
Source: Brian Long's old goodies
Update:
I had to replace a couple of TEdit by TDBEdit on our main project at work and this trick worked.
But on a new Project with 3 Forms, it failed consistently to write/commit/save the changes on the last Form (same environment).
FYI, I tried with and without DDevExtensions 2.5 and IDEFixPack 4.6.1
Update2:
Went digging in the GExperts forum as suggested by Ulrich and finally found a possible explanation. The new property Touch does not like being copied from one component to another when the source is destroyed (causing the AV).
The suggested workaround is to do a bidirectional mapping in the Expert Settings to disable the copy for this property:
You might be running into this bug while trying to copy the Touch property from the old to the new component, but it has a workaround you can fairly easily test:
http://tech.groups.yahoo.com/group/GExpertsDiscuss/message/3994
Details:
There is a limitation/bug in Delphi 2010 and XE where if you assign a
Component.Touch property from one component to another and destroy the
original component that the new component becomes corrupt (it isn't
like component/interface references, where they either auto-correct
themselves or are reference counted).
For the moment, you can assign a bi-directional replace component
property map from TPanel.Touch to TGroupBox.Touch (use the two components being replaced in your specific case) that is marked as
a disabled property map, and that will work around this problem. Our next release
will not try to assign that property any longer.
GExperts 1.36 is also now available and includes a workaround for this issue. The workaround has been in the GExperts version control system and in testing for several weeks already.

How I can add some items to the code completion combobox of the Delphi IDE

I'm working in a Delphi IDE expert and I wonder if it's possible add new items to the code completion combobox displayed by the Delphi IDE when the user press CtrlSpace
UPDATE:
What I need is add items to the code completion list based in a specified type.
example suppose which I have a type called TMytype, what I want to do is add addional items to the code completion list when the user type a variable of the type TMytype
check this image
I found your question somewhat confusing but if you are in search of credible source on "Custom Live Templates" and the like on Delphi, head to the blog of Cary Jensen here.
Edit:
Looking forward to further improvement of the scope of the question, I suggest here another direction to explore:
Source code manipulation using IOTAEditor, IOTASourceEditor, IOTAEditReader and the like
Some Parsing for sanity check prior to apply any modification.
Adoption of Client DataSet as a format to store data (It's serializable) to simplify the coding of IDE editors.
Perhaps I haven't fully grasped the extent of what you are asking here, but you can add templates simply by going to 'View|Templates' from the Delphi IDE. This then opens a template viewer. Press the '+' icon. It opens a template1.xml document which you can then edit so create your new item.
If you wish to do this programatically, just add an xml file (of the same format) to the ..\RAD Studio\code_templates folder.

Derive IntraWeb forms from parent and not TIWAppForm directly - error in IDE

I have forms in my application that I derive from a common ancestor, like:
TAtFormBaseIW = class( TIWAppForm )
and
TAtFormExplorerIW = class( TAtFormBaseIW )
This works for certain forms, but not for others.
Let me make a wild guess: it seems to work for all forms that where created in Delphi prior to IW 10, but not for forms I created with IW 10. What happens with newer forms: HWenever I want to load them into the IDE, they are interpreted as win32 forms, some properties are ignored (all typical win32 properties such as ClientWidth), and I am told that I cannot put IW components on these forms.
Making them direct descendants of TIWAppForm, saving them and using a normal text editor to change them back works. After a recompile they show up fine in the browser, but never in the IDE.
Any idea of what is happening?
Mea culpa, mea maxima culpa. This problem has nothing to do with IntraWeb, but with the way a derived form should be added to the project.
Instead of just changing TIWAppForm to TAtFormBaseIW, after having added a new form to the project, I should do this:
Select in the IDE
File / New / Other / Inheritable Items
and then the base form you want to derive your form from.
If you want to turn an existing form into a derivate, also change the leading key word object in the dfm file to inherited.
You can read about this here.

Delphi Short Cut to add Date and Name Comment

Does anyone know of a short cut to place my name and the date where the cursor is i.e.
//021208 DarkAxi0m
so i don't keep check what the date is when i'm adding comments.
Im using Delphi7, with CnPack And GExperts Installed.
I think it should be able to be done with one of those experts.
I use GExperts to do this, like so:
in the
GExperts\Configuration
Select the Editor Experts tab.
In the list of experts, select
Insert Date\Time
Click on the configuration, insert the desired text:
'//' ddmmyy 'DarkAxi0m: '
//021208 DarkAxi0m:
After, to insert your new Date name comment all you need to do is:
ctrl+alt+a
I setup most programmers at the job like that.
It is also simple to do with GExperts' Expand Macro Template (found in Editor Experts).
I use this expansion to insert yyyy-mm-dd at the current position:
%YEAR%-%MONTH%-%DAY%|
For a solution that will work in most applications under Windows, not only in Delphi, you can use Authotkey (free, autohotkey.com). One of its many features is the ability to expand strings that you type - typically used for autocorrecting typos.
I start all my shortcut strings with a semicolon, since it practically never leads strings I type in real life, so in your example, to insert a comment-date-username sequence, I would want to type semicolon, slash, slash:
;//
The Authotkey script (which you can put in an .ahk text file and add the file to Autostart) would look like this:
::;//:: ; this means: when I type ";//", do what follows
FormatTime, curDate,, yyyy-MM-dd ; the double comma is intended
SendInput // %curDate% %A_UserName% ; variable expansion
return
This produces the following output:
// 2008-12-05 moodforaday
AHK syntax is a little dense, but there is an extensive help file.
On edit: this script could be expanded to apply the correct comment syntax depending on the IDE you are working in at the moment. You would detect active window title, find a signature substring ("Delphi") and choose the proper comment character(s). This way you could type the same hotstring to insert your comment regardless of the current IDE or language. You can also use SendInput to position the caret the way Delphi templates do.
Never mind found one in CnPack/Soure Templates
Added the template
//%Date% DarkAxi0m
Note: i should look in the menus more closely
You might also look at the Live Templates feature, which can be scripted to do just what you want:
http://cc.codegear.com/Item/24990
Don't be put off by the name, it includes a template script to include the date, time, including the ability to format it as you want.
Here is a variation with GExperts (www.gexperts.org) that makes it easy to search for changes based on developer or date.
Example of output and comment:
//07.25.2009 (SLB20090725) - Added 3rd optional parameter.
Besides an easily readable date I can easy search for comments programmer, by year, year+month etc.)
For example I can search for (SLB200905 for any comments I logged in May of 2009.
To do:
Under the GExperts menu open Configuration... (at the bottom of the list) then select the Editor Experts tab.
Locate 'Insert Date/Time' and double click on it.
//mm.dd.yyyy '(ABC'yyyymmdd') -'
Where ABC is the programmers name, initials, id, or whatever.
Then use Ctrl-Alt-A when in Delphi's IDE to insert
This should work in any verison of Delphi supported by GExperts.

Resources