Recent

Author Topic: [SOLVED] DBGridUserCheckboxBitmap procedure is not called  (Read 5837 times)

patyi

  • Full Member
  • ***
  • Posts: 168
[SOLVED] DBGridUserCheckboxBitmap procedure is not called
« on: March 03, 2019, 11:49:24 am »
Hi all !

The DBGridUserCheckboxBitmap procedure is not executed at all. I'm try with debuger but debuger is not  go inside this procedure.
Am I missing some properties to adjust or it is bug in DBGrid ?

Code: Pascal  [Select][+][-]
  1. procedure TFUlazniRac.DBGridUserCheckboxBitmap(Sender: TObject;
  2.   const CheckedState: TCheckboxState; var ABitmap: TBitmap);
  3. begin
  4.   if CheckedState = cbChecked then
  5.     FDataMod.ImageList.GetBitmap(7, ABitmap)
  6.   else if CheckedState = cbUnChecked then
  7.     FDataMod.ImageList.GetBitmap(16, ABitmap)
  8.   else
  9.     FDataMod.ImageList.GetBitmap(17, ABitmap);
  10. end;  

The DBGrid shows the standard CheckBox images !

Lazarus 2.0.1 fixes 64 bit, FPC 3.0.5 fixex 64 bit, XUbuntu 64 bit.
« Last Edit: March 04, 2019, 03:25:38 pm by patyi »

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #1 on: March 03, 2019, 02:59:30 pm »
I think that was a problem that got fixed.
The only true wisdom is knowing you know nothing

patyi

  • Full Member
  • ***
  • Posts: 168
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #2 on: March 03, 2019, 04:33:31 pm »
I'm updated my Lazarus/FPC fixes instalation, ther is no change !  May be the Trunc got fixed ?

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #3 on: March 03, 2019, 07:27:16 pm »
Yes, most likely../.

Look at the history at the Lazarus.org site .
The only true wisdom is knowing you know nothing

patyi

  • Full Member
  • ***
  • Posts: 168
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #4 on: March 03, 2019, 08:42:25 pm »
No, is not fixed in the Trunc ! I'm Install Lazarus Trunc, the result is the same, DBGridUserCheckboxBitmap procedure was not call at all !

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #5 on: March 03, 2019, 09:13:47 pm »
Patyi, although such code used to work, it has always been wrong -- you should create the bitmap yourself and then assign it to ABitmap parameter.

See: http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes#TCustomGrid:_The_var_parameter_ABitmap_in_event_OnUserCheckBoxBitmap_used_to_be_preassigned_with_default_bitmap.2C_but_now_it_is_nil

Read Ondrej's posts about it here:
https://bugs.freepascal.org/view.php?id=35085

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #6 on: March 03, 2019, 09:16:04 pm »
The problem is that TDBGrid implements its own event type for OnUserCheckboxBitmap, different from the one used by TCustomGrid. When you assign an event handler to OnUserCheckboxBitmap of TDBGrid the OnUserCheckboxBitmap of TCustomGrid remains unassigned.

The checkboxes are painted by DrawGridCheckboxBitmaps inherited from TCustomGrid. Here the TCustomGrid queries whether a handler is assigned to its OnUserCheckboxBitmap, and since there is none in case of the TDBGrid it proceeds with the standard checkbox bitmap.

I reopened the bug report mentioned by Zoran.
« Last Edit: March 03, 2019, 09:27:32 pm by wp »

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #7 on: March 03, 2019, 09:20:27 pm »
The problem is that TDBGrid implements its own event type for OnUserCheckboxBitmap, different from the one used by TCustomGrid. When you assign an event handler to OnUserCheckboxBitmap of TDBGrid the OnUserCheckboxBitmap of TCustomGrid remains unassigned.

The checkboxes are painted by DrawGridCheckboxBitmaps inherited from TCustomGrid. Here the TCustomGrid queries whether a handler is assigned to its OnUserCheckboxBitmap, and since there is none in case of the TDBGrid it proceeds with the standard checkbox bitmap.

You should file a bug report.

You are right. But this will be fixed when the patch in 35097 gets applied.

@Zoran: You post works only for TStringGrid and TDrawGrid, but not for TDBGrid where the event handler is not called due to incompatible events.


Yes. I understand now. Still, the patch from 35097 should fix this issue.
« Last Edit: March 03, 2019, 09:22:23 pm by Zoran »

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #8 on: March 03, 2019, 10:53:52 pm »
Yes, the patch fixes the issue. I applied it.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #9 on: March 04, 2019, 08:09:14 am »
Thank you, Werner.

Patyi, note that you still have to change your code according to what I pointed above.
Please tell us is your problem solved now (with fresh Lazarus trunk).

patyi

  • Full Member
  • ***
  • Posts: 168
Re: DBGridUserCheckboxBitmap procedure is not called
« Reply #10 on: March 04, 2019, 10:08:31 am »
Thank you wp & Zoran!

It works now ! I updated Lazarus Trunc, changed the code as Zoran suggested.
Another request if this change could be made in the Lazarus 2.0 Fixes brunch ? I'm not using Trunc for development, just for testing ...  O:-)

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
« Reply #11 on: March 04, 2019, 10:14:18 am »
Normally new features (here: new event) are not back-ported to fixes. What is the risk that the fix will damage anything?

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
« Reply #12 on: March 04, 2019, 10:52:26 am »
Normally new features (here: new event) are not back-ported to fixes. What is the risk that the fix will damage anything?

True, but here we actually had a regression (db grid does not draw custom-drawn check boxes).
The applied patch adds new behaviour AND, as a side effect, solves this.

The solution might be to separate this in two patches - one which solves the problem with drawing grid in check boxes and another one which adds new feature.

Now, I can provide the two patches, but then, Werner, you should revert the changes, apply the first patch, request backporting, and then apply the other.

Werner, what do you think? If you agree with this scenario, revert the changes, and I will provide the two patches then. Please tell us your opinion.

patyi

  • Full Member
  • ***
  • Posts: 168
Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
« Reply #13 on: March 04, 2019, 11:00:15 am »
wp you are right, and I don't want to open my dispute but the DBGridUserCheckboxBitmap event is not new, it already existed in 2.0 (I think it was already in 1.8 ). Something has changed in the code that doesn't work. So I think it is natural to fix it in 2.0 Fixes. I'd be happy if you were repaired, but the thing is just aesthetic change on the program, so it's not vitally important ... thanks !

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
« Reply #14 on: March 04, 2019, 11:16:12 am »
Zoran, I removed the OnUserCheckboxImage event from trunk and put r60571+60578 on the merge request list. I though I could apply your original patch again to bring in the event, but this does not seem to work. Could you prepare a patch for the event based on the current state of trunk (r6078)?

 

TinyPortal © 2005-2018