Recent

Author Topic: TDBCtrlGrid porting  (Read 463 times)

Nicola Gorlandi

  • Jr. Member
  • **
  • Posts: 80
TDBCtrlGrid porting
« on: November 06, 2019, 01:52:12 pm »
I need to port in Lazarus a project that use a TDBCtrlGrid. The project will run only in Windows
Is someone avaiable to implement this porting ?
In case I can pay for this job (after an agreement).

Many thanks.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7630
Re: TDBCtrlGrid porting
« Reply #1 on: November 06, 2019, 02:15:48 pm »
Port from where exactly? The delphi code is copyrighted and can't be used.

devEric69

  • Full Member
  • ***
  • Posts: 164
Re: TDBCtrlGrid porting
« Reply #2 on: November 11, 2019, 06:38:40 pm »
When you want to display other components in a TDBGrid (to emulate a TDBCtrlGrid), you have to "embed" them, following these principles, basically:
- when displaying, the dbGrid is drawn.
- when a cell is selected, it is necessary to embed a component in the cell and give it focus.
- when the component is left (tab, mouse key elsewhere, the component must be unlocked, the grid must have focus, and even redraw itself with the control data.

For overlay, several levels can be used for focus transfers between a cell and the overlay control:
- control incrustation when a cell has the focus, without giving the focus to the control.
- transfer from focus to control only for data entry.

Some general rules can therefore be identified:
- the display of the embedded control can be done in OnDrawDataCell, when dgFocused is part of the State parameter. Events like OnEnter can also be used for this purpose.
OnDrawDataCell is not normally designed for this: it is used to refresh the screen, i.e. to explain how to draw the TRec from the cell by the OS, but...
- unincrust, i. e. assign Visible:= False can be done in TControl.OnExit, and in dbGrid.OnColExit (but does not cover the case of a vertical movement in the same column).
- you must manage keyboard events when the control is embedded, visible. First, it is necessary to make the focus shift between the control and the dbGrid homogeneous:  therefore, you can code the typing of the Tab and navigation arrows keys.

All this, to say that it's not simple (it's just to show the minimal logic, how to replace the inPlaceEditor with other controls). In my humble opinion, the most pragmatic thing is to look at the code of the component that have been notified by Zoran (see https://forum.lazarus.freepascal.org/index.php/topic,47319.msg338673.html#msg338673), and adapt it so that it'll work with your database too.

Two cents.
« Last Edit: November 11, 2019, 06:40:44 pm by devEric69 »
use: Ubuntu 18.04 + Laz. 1.8.5 + FPC 3.0.5 (64 bits).

PascalDragon

  • Hero Member
  • *****
  • Posts: 735
  • Compiler Developer
Re: TDBCtrlGrid porting
« Reply #3 on: December 07, 2019, 07:54:44 pm »
This post is already a month old, but I remembered something I recently found: the company MWA Software provides a TDBControlGrid in their Open Source IBX for Lazarus software (the code is here). As it's based on the LCL's grid it's also under LGPL-with-static-linking-exception. Maybe that could even be integrated in Lazarus...