Lazarus

Programming => LCL => Topic started by: patyi on March 03, 2019, 11:49:24 am

Title: [SOLVED] DBGridUserCheckboxBitmap procedure is not called
Post by: patyi 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.
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: jamie on March 03, 2019, 02:59:30 pm
I think that was a problem that got fixed.
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: patyi 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 ?
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: jamie on March 03, 2019, 07:27:16 pm
Yes, most likely../.

Look at the history at the Lazarus.org site .
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: patyi 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 !
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran 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 (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 (https://bugs.freepascal.org/view.php?id=35085)
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: wp 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.
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran 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 (https://bugs.freepascal.org/view.php?id=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.
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: wp on March 03, 2019, 10:53:52 pm
Yes, the patch fixes the issue. I applied it.
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran 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 (https://forum.lazarus.freepascal.org/index.php/topic,44519.msg313081.html#msg313081).
Please tell us is your problem solved now (with fresh Lazarus trunk).
Title: Re: DBGridUserCheckboxBitmap procedure is not called
Post by: patyi 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:-)
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: wp 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?
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran 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 (http://wiki.freepascal.org/Lazarus_2.0_fixes_branch#Merge_requests), 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.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: patyi 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 !
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: wp 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)?
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran on March 04, 2019, 11:24:02 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)?

I'll take a look.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: Zoran on March 04, 2019, 11:45:11 am
I'm attaching the patch here.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: wp on March 04, 2019, 12:28:06 pm
Applied, thanks.

patyi: Now the part of Zoran's original patch which fixes the custom checkboxes in TDBGrid will be backported to the fixes branch; the remainder, the new OnUserCheckboxImage event, remains in trunks as a new feature and will be included in Laz 2.2.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: patyi on March 04, 2019, 01:15:22 pm
wp, thanks, but Lazarus 2.0 Fixes don't work, procedure DBGridUserCheckboxBitmap is not executed ! (tested with debuger, not entering in the DBGridUserCheckboxBitmap)
Trunc is Ok.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: wp on March 04, 2019, 01:37:23 pm
I did not say that it is in fixes, just that it will be. We have a list of fixes to be merged (http://wiki.lazarus.freepascal.org/Lazarus_2.0_fixes_branch), and every couple of days one of the main developers merges them. So, please be patient.
Title: Re: [SOVED IN TRUNC] DBGridUserCheckboxBitmap procedure is not called
Post by: patyi on March 04, 2019, 02:07:56 pm
Sorry thet I am to quick ... I will be patient !  8-)
Title: Re: [SOLVED] DBGridUserCheckboxBitmap procedure is not called
Post by: patyi on March 07, 2019, 09:42:39 am
I just want to confirm that Lazarus 2 DBGridUserCheckboxBitmap is now working !  :D
TinyPortal © 2005-2018