Problems with Aero Glass in Delphi 7 applications

Posted by Cralias on Stack Overflow See other posts from Stack Overflow or by Cralias
Published on 2010-05-19T10:17:18Z Indexed on 2010/05/19 10:20 UTC
Read the original article Hit count: 693

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-7