views:

440

answers:

1

Hi everyone!

I'm trying to remake some of my older projects to support Aero Glass. Although it's kinda easy to enable glass frame, I've encountered some major problems. I used this code:

var
  xVer: TOSVersionInfo;
  hDWM: THandle;
  DwmIsCompositionEnabled: function(pbEnabled: BOOL): HRESULT; stdcall;
  DwmExtendFrameIntoClientArea: function(hWnd: HWND; const pxMarInset: PRect): HRESULT; stdcall;
  bEnabled: BOOL;
  xFrame: TRect;

// ...

  xVer.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  GetVersionEx(xVer);
  if xVer.dwMajorVersion >= 6 then
  begin
    hDWM := LoadLibrary('dwmapi.dll');
    @DwmIsCompositionEnabled := GetProcAddress(hDWM, 'DwmIsCompositionEnabled');
    @DwmExtendFrameIntoClientArea := GetProcAddress(hDWM, 'DwmExtendFrameIntoClientArea');
    if (@DwmIsCompositionEnabled <> nil) and
       (@DwmExtendFrameIntoClientArea <> nil) then
    begin
      DwmIsCompositionEnabled(@bEnabled);
      if bEnabled then
      begin
        xRect := Rect(-1, -1, -1, -1);
        DwmExtendFrameIntoClientArea(FrmMain.Handle, @xRect);
      end;
    end;
    FreeLibrary(hDWM);
  end;

So I got the pretty glass window now. Due to black being transparent color now (kinda stupid choice, why couldn't it be pink) anything that is clBlack becomes transparent, too. It means all labels, edits, button texts... even if I set text to some other color at design time, DWM still makes them that color AND transparent.

Well, my question would be - whether it's possible to solve this somehow?

+1  A: 

Delphi 7 and all the versions till D2006 has also other problems with Windows Vista and newer.

Delphi 2007 is the fist certified version for Vista. My advice is to upgrade to Delphi 2010. Your effort to patch Delphi 7 is imho too big for the outcome. Ok, perhaps you will need to convert your application to Unicode (a far less painful process than it sounds - especially if you use Embarcadero's forums and/or this site) but it's worth the effort. And this not only for Vista compatibility but also for all the goodies which are packed with newer versions of Delphi, especially with Delphi 2010.

HTH

People sometimes say "if it ain't broke, don't fix it".But perhaps it is time to move on. I'll check the trial version of 2010.Thx ;)
Cralias
However, on Vista+ it is a bit broken
Gerry
@Gerry: "*It* is a bit broken..." who "It"? Delphi 7 or Delphi 2007? I think I was clear in my answer...
With "ain't broke" I meant - my apps works ok on Vista+, except they do not have that eye candy which isn't actually a requirement.Anyway, checking out 2010 now. Seems that placing most controls directly on the glass surface is not really a good idea ANYWAY.Looking for workarounds...
Cralias
Problem solved.If TLabel is placed on glass surface, I set it's GlowSize to nonzero value. And for forms I set DoubleBuffered = true. Buttons need explicit Refresh, when enabling/disabling. So far so good.Now that 2010 costs quite a bit, but it's worth it, I think.Thanks, plainth ;)
Cralias
See also this issue: http://stackoverflow.com/questions/3334191/delphi-buttons-show-white-border-on-aero-glass/3347626#3347626
Warren P