Recent

Author Topic: Porting TSortGrid to Lazarus  (Read 3663 times)

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Porting TSortGrid to Lazarus
« on: August 28, 2021, 03:35:39 pm »
Dear ALL,

Searching for a TStringGrid descendent with enhanced capabilities, I came across a TSortGrid (https://torry.net/files/vcl/grids/stringgrids/bksgrid.zip) 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):

Description
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,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

fred

  • Full Member
  • ***
  • Posts: 201
Re: Porting TSortGrid to Lazarus
« Reply #1 on: August 28, 2021, 03:56:20 pm »
There is a SortGrid in OPM (not tried it), the home page is https://github.com/JohnML1/SortGrid
Edit: Forget it, it's not the same, only al very simple sort function added.
« Last Edit: August 28, 2021, 04:02:41 pm by fred »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Porting TSortGrid to Lazarus
« Reply #2 on: August 28, 2021, 06:25:58 pm »
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.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Porting TSortGrid to Lazarus
« Reply #3 on: August 28, 2021, 06:39:23 pm »
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 (https://wiki.lazarus.freepascal.org/Grids_Reference_Page) 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.

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: Porting TSortGrid to Lazarus
« Reply #4 on: August 28, 2021, 08:51:13 pm »
@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,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

 

TinyPortal © 2005-2018