Workaround on TDBNavigator,TSpeedButton bug
Posted February 15th, 2009 by Issam
in
I read a comment on Andreas Hausladen blog asking for help with TDBNavigator bug QC52439 , I think everybody knows the great efforts that Andress gives to the Delphi community, so i decided to give Andress a hand on this
and here is my workaround about this bug:
note: this bug exists in Delphi2007 and Delphi2009
1- open "Buttons" unit.
2- in the TSpeedButton class locate these lines in the Paint Procedure
...
if not PaintOnGlass then
if Transparent then
ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False)
...
if not PaintOnGlass then
if Transparent then
ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False)
...
and modify them like this
...
if not PaintOnGlass then
if Transparent then
Begin
PerformEraseBackground(Self, Canvas.Handle);
ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False);
End
...
if not PaintOnGlass then
if Transparent then
Begin
PerformEraseBackground(Self, Canvas.Handle);
ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False);
End
...
(re)compile the unit and that will solve the problem and maybe other problems caused by this bug.
Regards
{ Arabic Programmer; }
Comments
Thanks Issam. Can’t test
Thanks Issam. Can’t test this myself but I believe it works.
What I can't understand is
What I can't understand is what this code is doing:
My logic is as follow:
We are in the Paint method so the Invalidate method have just called and since Transparent = True - csOpaque is not in ControlStyle and InvalidateRect in Invalidate is called with bErase = True so the background is erased, TSpeedButton is a TGraphicComtrol and in this moment we see what is underneath.
Please, explain me what I lose?
re:What I can't understand is
"and in this moment we see what is underneath"
that's true if we are not in themed mode but in themed mode that is not enough, we have to tell theme service to Draw the background of the control's parent and that's what method DrawParentBackground do (actually by calling the API function DrawThemeParentBackground)
why?
because in themed mode we use DrawElement procedure to Draw (actually by calling API Function DrawThemeBackground)and with this function if you want transparency you must use DrawThemeParentBackground function before.
more detail:
http://msdn.microsoft.com/en-us/library/bb773306(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb773289(VS.85).aspx
regards,
I didn't know that
I didn't know that DrawElement calls DrawThemeBackground (and it's necessary DrawThemeParentBackground to be called first in order to achieve transparent effect).
Thanks Issam.
Post new comment