Workaround on TDBNavigator,TSpeedButton bug

Some comments on Andreas Hausladen blog asked for help in this TDBNavigator bug QC52439 , I think everybody knows Andress and his great efforts to the Delphi community, so i decided to give Andress a hand on this Wink and here is workaround for 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)

and modify them like this

    if not PaintOnGlass then
      if Transparent then
          PerformEraseBackground(Self, Canvas.Handle);
          ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False);

(re)compile  the unit  and  that will solve the problem and maybe other problems caused by this bug.


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:

if Transparent then
  ThemeServices.DrawParentBackground(0, Canvas.Handle, nil, False)

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)
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:


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

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Tables will be rendered with different styles for even and odd rows if supported.
  • Textual smileys will be replaced with graphical ones.
  • You may quote other posts using [quote] tags.
  • You can highlight code with any of the following tags: <code>, <cpp>, <cs>, <delphi>, <xml>

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.
Syndicate content