Just found by accident: When editing a .pas unit, Shift + Ctrl + [ArrowUp or ArrowDown] jumps from procedure declaration to implementation. Very nice if you have large units with several thousands of lines and numerous procedures and functions.
Kategorie: Delphi
Link: ftp://ftp-developpez.com/sjrd/tutoriels/delphi-generics/delphi-generics.pdf
Just found a wonderful and deep look into generics, anonymous routines and routine references here . Written by Sébastien Doeraene.
Generics were introduced in Delphi 2009, and I'm a big fan of them, as they help me do less type casting on TObjectList's items for example.
Want to know how sorting a TObjectList<TWhatever> works? Here's how it works:
type
TDBObject = class
Name: String;
end;
TDBObjectList = TObjectList<TDBObject>;
TDBObjectComparer = class(TComparer<TDBObject>)
function Compare(const Left, Right: TDBObject): Integer; override;
end;
procedure TMainform.btnOkClick(Sender: TObject);
var
o: TDBObject;
begin
Result := TDBObjectList.Create(TDBObjectComparer.Create);
o := TDBObject.Create;
o.Name := 'foo';
Result.Add(o);
o := TDBObject.Create;
o.Name := 'bar';
Result.Add(o);
end;
function TDBObjectComparer.Compare(const Left, Right: TDBObject): Integer;
begin
Result := CompareText(Left.Name, Right.Name);
end;
Link: http://www.soft-gems.net/index.php?option=com_content&task=view&id=56&Itemid=1
Mike has just set up a bugtracker at Google Code for his popular VirtualTree component for Delphi. So, finally, all interested developers can actively participate in enhancing and extending this thing.
HeidiSQL makes extensive use of VirtualTree - as replacement for the normal TTree's and TListView's we had in old days. VirtualTree can display tree-like structures as well as lists, in all colors and flavours you can imagine:

Much more: it minimizes CPU and memory usage by strictly following the virtual paradigm (= just process visible nodes, nothing more, the rest is processed when the users scrolls to it). That means you can create millions of nodes in milliseconds. It has support for drag'n drop, custom cell editors (similar to plugins), images in column headers and cells, tons of useful events, and numerous other things you won't like to miss once you get used to them.
Imagine some ordinal type and a set enumeration of it in Delphi:
Code:
type | |
TLocation = (locHere, locThere, locElsewhere); | |
TLocations = Set of TLocation; | |
... | |
var locs: TLocations; | |
... | |
begin | |
Include(locs, locHere); | |
end; |
Now, imagine you have several loops and points where any TLocation is added to or substracted from locs. At a later point in your application you need the number of elements in locs. Although that seems totally trivial that is not implemented in Delphi's compiler. The only SET related procedures in Delphi's compiler are Include, Exclude and In - there is no Count method for SETs. Well, you can help out and write your own one, as I discovered here:
Code:
function CountSetItems(SetValue: Integer): Byte; | |
var | |
Mask: Integer; | |
begin | |
Mask := $80000000; | |
Result := 0; | |
while Mask <> 0 do begin | |
if SetValue and Mask <> 0 then | |
inc(Result); | |
Mask := Mask shr 1; | |
end; | |
end; |
