I am still using Delphi2006 for my database projects, but two days ago I’ve started a small Database App in Delphi2009, and it was a shock when I discovered that there is an obvious bug in TDBGrid in Delphi2009, Delphi2009 Update1 and Delphi2007, this bug will be “visible” if you change the BiDiMode property of TDBGrid to bdRightToLeft.
-Start a new vcl Application
-add a DBGrid and assign it to a DataSource and let it has some records.
-change BiDiMode property of the DBgrid to bdRightToLeft.
-run the application.
-try to move the form that contains the DBgrid beneath any other window or the Taskbar and you will notice the mess in the DBgrid canvas and may be you will see something like this.
By doing some searches using Google and Quality Central I didn’t find any mention to this bug, well! maybe this indicates that Delphi doesn’t have many fans in Arabic or Hebrew regions, the languages that use right to left writing, also I think CodeGear “itself” doesn’t have much interest in Arabic market, and we “as Arabic Developers” understand that, because of the troubles in the software industry in Arabic region, and I hope not in software industry only ;) even I think Gulf market (which is dominated now by Oracle tools and Java) could be a good opportunity for CodeGear and Embaracadero, I can post about this Later but now let us go back to the Bug. here is the reason and solution:
In Delphi2007 and Delphi2009 CodeGear implements a new version of TWinControl.WMPaint procedure, in this new version we paint only the update region instead of painting the entire ClientRect like in the old version, and using the API function BeginPaint in TDBgrid seams doesn’t work with RightToLeft mode, so here is my quick solution, maybe it’s not the perfect one but it works.
My solution is to (re)implement the WMPaint procedure (WM_PAINT message) in TCustomDBGrid class and make the update region equal to the client rectangle (like the old versions), especially I didn’t notice this bug in other TWinControl descendants.
private
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
.
.
.
procedure TCustomDBGrid.WMPaint(var Message: TWMPaint);
var
Rect: Trect;
begin
if UseRightToLeftAlignment then
Begin
Rect.TopLeft := ClientRect.TopLeft;
Rect.BottomRight := ClientRect.BottomRight;
InvalidateRect(Handle,@Rect,false);
End;
Inherited;
end;
I've QC'd this bug in #70075.
this is a quick solution but any other suggestions are welcomed.
Merry Christmas every one :)
التعليقات
I've mentioned it in QC
I've mentioned it in QC #69465.
BTW, Arabic and Hebrew are not the only right-to-left languages in the world.
Regards
I've checked QC #69465,
I've checked QC #69465, actually you are right it works well with ADO DataSets !
Thank you very much
Thank you very much
another workaround
The bug is in double-buffering code in TWinControl.WMPaint. The workaround is to disable double-buffering for the dbgrid: DBGrid1.DoubleBuffered := false.
If you use the grid with TClientDataSet, you can set dataset's ObjectView property to false since it also disables double-buffering (unlike DoubleBuffered, ObjectView can be changed in design time).
Thank you very much!
Hi,
I'm a chinese programer.
I'm implement a arabic soft.
Thanks for your ids!
Br,
Tag
btw,I used 'GetUpdateRect(Handle, rc, False);'
but it 's not work.
THANK YOU VERY VERY MUCH !!!
THANK YOU VERY VERY MUCH !!!
YOU HAVE SAVED ME !
DELPHI IS THE BEST OF ALL !
إضافة تعليق جديد