4

The other day, I started to play with different visual effects in Delphi, and ran into a problem using Aero Glass effect (I have a Delphi 2010 installed): when I put the button on the glass, some part of this button (or some other element) burns and becomes transparent. I don't know why, but I tried to do the same example on the other computers. And this bug repeated.

Screenshot with a bug; the second button's caption is transparent: enter image description here

My example program:

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 202
  ClientWidth = 331
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  GlassFrame.Enabled = True
  GlassFrame.Bottom = 50
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 64
    Top = 153
    Width = 175
    Height = 41
    Caption = 'Button1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clMenuHighlight
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
  end
  object Button2: TButton
    Left = 64
    Top = 73
    Width = 175
    Height = 41
    Caption = 'Button1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clMenuHighlight
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 1
  end
end
Warren P
  • 65,725
  • 40
  • 181
  • 316
impulsgraw
  • 887
  • 3
  • 13
  • 34
  • 3
    Just to clarify: Aero is a Windows thing, not a Delphi thing. – Andreas Rejbrand Apr 15 '13 at 15:50
  • 1
    Your code would appear to contain a bug. Please add the code to the question. A small, complete compilable program please. – David Heffernan Apr 15 '13 at 15:51
  • FYI: Aero glass will only work on Windows 7, AFAIK. As Andreas points out, this is part of Windows, so don't expect this to work on all versions of Windows. – Jerry Dodge Apr 15 '13 at 16:55
  • 5
    Of course it won't work on all versions of Windows, @Jerry, but I think it's reasonable to at least expect it to work on versions that support Aero. The appearance of the form in the question suggests it's running on such a version. The question is why the button doesn't look right. – Rob Kennedy Apr 15 '13 at 17:06
  • I can confirm the same behavior from .NET, so this will be the system wide problem. It's not easy to draw even plain text on aero sheet of glass (even with GDI+). – TLama Apr 15 '13 at 17:31
  • Areo is on Vista, 7 and 8. – David Heffernan Apr 15 '13 at 17:32
  • @David, try to change your theme color to white. Андрей Ильичёв, about [`ribbon control`](http://stackoverflow.com/q/6490900/960757). – TLama Apr 15 '13 at 17:34
  • @David, http://windows.microsoft.com/en-ph/windows7/change-the-colors-on-your-computer. It works somehow fine if you have a dark theme, but it's perfectly visible if you have white theme and you move the form in front of a white space. – TLama Apr 15 '13 at 17:35
  • @David: But I believe there is no glass in Windows 8's implementation of Aero. I wonder how this would look in Windows 8... – Andreas Rejbrand Apr 15 '13 at 17:37
  • There's glass but the default themes don't use it. They could hardly take away all the glass apis and break all the programs. – David Heffernan Apr 15 '13 at 17:44
  • @Ken Yes, I know this, I was just making sure the OP knows this, because they seem to think it's a Delphi thing. – Jerry Dodge Apr 15 '13 at 18:31

1 Answers1

4

This is a known bug in Delphi 2010 support for "glass" (Aero Composition using DWM), I believe it was fixed in Delphi XE, and the workaround that I chose to use is to use my own custom TButton-like class.

I reported this bug to Embarcadero when I saw it in 2010, as did others, I can't seem to find the QC# (bug report #), but the suggested workaround with double-buffered is not acceptable to me. TBitBtn did not exhibit this problem I believe and was my simplest workaround, although it had other issues.

There are a lot of glass issues in Delphi 2010. General advice; Upgrade Delphi.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • I'd say the whole Windows Aero support was introduced in Delphi 2009. At least I could find everything necessary to reproduce this issue there. And, [`I could reproduce`](http://stackoverflow.com/questions/16019241/delphi-2010-button-with-windows-version-that-has-aero-glass-on-turns-text-white#comment22852116_16019241) the same with .NET WinForms application, so it's just the system who decides how to render that button caption on sheet of aero glass. Delphi would have to workaround this system issue in its implementation, I'd say. – TLama Apr 15 '13 at 23:03
  • 1
    The issue IS a Windows common controls issue at its root. – Warren P Apr 15 '13 at 23:44
  • 1
    Yes but you didn't said that in your answer. And the very same behavior you will see even with Delphi XE3, so nothing was *"fixed"*. Embarcadero would need to implement custom drawn button control to workaround this system issue (and it's [`not that easy`](http://stackoverflow.com/q/4258330/960757) even with GDI+). – TLama Apr 16 '13 at 06:43
  • I think they did work around it in XE and later, because I was unable to reproduce the issue after I used XE. Are other people still seeing this in XE,XE2,XE3? Remember that just because something is windows common controls issue, doesn't mean there aren't flags and things you can do if you are the author of the VCL, including calls to the DWM APIs, and other APIs. – Warren P Apr 16 '13 at 13:12
  • You can see this issue only if you have light theme color, such as white. Have you simulated this issue with a light [`Windows theme color`](http://stackoverflow.com/questions/16019241/delphi-2010-button-with-windows-version-that-has-aero-glass-on-turns-text-white/16025487?noredirect=1#comment22852231_16019241) ? – TLama Apr 16 '13 at 13:15