3
votes

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

1 Answers

3
votes

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