Jump to content

Frosted glass transparency


Josh
 Share

Recommended Posts

This is how I make transparent window effects:

// Enable transparency effects
#ifdef _WIN32
auto hwnd = window->GetHandle();

struct ACCENTPOLICY
{
  int na;
  int nf;
  int nc;
  int nA;
};
struct WINCOMPATTRDATA
{
  int na;
  PVOID pd;
  ULONG ul;
};

const HINSTANCE hm = LoadLibraryW(L"user32.dll");
if (hm)
{
  typedef BOOL(WINAPI* pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*);

  const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hm, "SetWindowCompositionAttribute");
  if (SetWindowCompositionAttribute)
  {
    ACCENTPOLICY policy = { 4, 0, 155, 0 };
    //ACCENTPOLICY policy = { 3, 0, 0, 0 }; // and even works 4,0,155,0 (Acrylic blur)
    WINCOMPATTRDATA data = { 19, &policy,sizeof(ACCENTPOLICY) };
    SetWindowCompositionAttribute(hwnd, &data);
  }
  FreeLibrary(hm);				
}			
#endif

You probably want to set your interface's background panel color to 0,0,0,1 for best results.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...