Forum > Ported from Delphi/Kylix

Porting TSortGrid to Lazarus


Dear ALL,

Searching for a TStringGrid descendent with enhanced capabilities, I came across a TSortGrid ( which offers a lot of quite useful features (some of which may be redundant, but others are not available in the current implementation of Lazarus TStringGrid):

TSortGrid is a highly improved TStringGrid, lots of new or improved functions, events and properties, to name a few:

* Search and Filter: Easy and fast, fully customable
* Sort: Different sorts, like numbers, date, your own
* Load & Save: Save to file and registry, export to CSV
* MultiSelect: Using Ctrl and Shift keys
* Components: Add button, picklist or checkbox to a cell
* Paint: Draw cells in lot of different ways
* Print: Print the grid, with preview
* Auto size Columns and much more....
I would like to port that component to Lazarus, but got a number of errors just in the beginning, reporting missing units (like MaskedEdit) which are, in fact, all there. The component comes in versions of Delphi5 and Delphi6 and I presume should be fully compatible with Lazarus, but it does not include a package file, which may, or may not, make the conversion more troublesome (I simply created a new package and added the source files to it).

Although I have already successfully converted a full project from Delphi to Lazarus, I still have no experience with converting components. Could anyone give me a hand? I believe that such a component might be of great use for the worldwide community of Lazarus developers.

With best wishes,

There is a SortGrid in OPM (not tried it), the home page is
Edit: Forget it, it's not the same, only al very simple sort function added.

Porting bksgrid to cross-platform Lazarus is not simple or easy.
The code uses quite a large number of Windows API calls, and requires a specific Windows .dll.

The code has several sections of Intel assembly routines.
The code uses a hack to make part of the stack seem like a heap.

The bitmap resources UP and DOWN are not supplied, but are required for successful compilation. There seem to be two missing units WinUtils and Consts.

Probably all of these obstacles (with patient work and sufficient time and experience at translating Windows message calls to cross-platform equivalents) can be overcome. But it is not a task for a beginner at converting components.

I think this is not worth the (huge) effort: This TSortGrid was written in the early days of Delphi when Delphi's TStringGrid was very limited. The present LCL TStringGrid, on the other hand, has most of the features of TSortGrid; filtering and printing are the only ones in that list which are not readily available. So, rather than fighting with TSortGrid I'd recommend that you carefully read the LCL grid documentation ( and study its source code. Then you can look at the TSortGrid and try to port its filtering/printing capabilities to your LCL-TStringGrid descendant.

@howardpc, @wp.

In fact, I have not examined in detail the code of TSortGrid. If I had done that beforehand, I would have glimpsed the ugly things hidden there (Windows API calls! Intel assembly code!) and surely would not had even opened this thread.  :o

My it rest, with a warning for other unwary developers, as in the old medieval maps: Here be dragons.

With best regards,


[0] Message Index

Go to full version