Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th December 2021, 01:00   #1  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,222
How to enable "glass" effect in Windows 11 (DWM) ?!

Does anybody know how to get a proper "glass" effect on Windows 11?

Every since Windows 7, I have been using this code to enable the "glass" effect on a window:

Code:
bool MUtils::GUI::sheet_of_glass(QWidget *const window)
{
        /* Code to load "dwmapi.dll" and look up the required functions is excluded*/

	//Enable the "sheet of glass" effect on this window
	MARGINS margins = {-1, -1, -1, -1};
	if(HRESULT hr = dwmExtendFrameIntoClientAreaFun(reinterpret_cast<HWND>(window->winId()), &margins))
	{
		qWarning("DwmExtendFrameIntoClientArea function has failed! (error %d)", hr);
		return false;
	}

	//Create and populate the Blur Behind structure
	DWM_BLURBEHIND bb;
	memset(&bb, 0, sizeof(DWM_BLURBEHIND));
	bb.fEnable = TRUE;
	bb.dwFlags = DWM_BB_ENABLE;
	if(HRESULT hr = dwmEnableBlurBehindWindowFun(reinterpret_cast<HWND>(window->winId()), &bb))
	{
		qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
		return false;
	}

	//Required for Qt
	window->setAutoFillBackground(false);
	window->setAttribute(Qt::WA_TranslucentBackground);
	window->setAttribute(Qt::WA_NoSystemBackground);

	return true;
}
Result on Windows 7 looks like this:



Windows 8.1 and Windows 10 still looks sort of "okay":



But on Windows 11 it looks like... that:



So, background is just not rendered at all on Windows 11, making the window totally transparent and looking kind of "broken". Any idea why that is?

What I'd actually like to have is a semi-transparent "smoked glass" effect, as in the Windows 11 startmenu and settings menus:
https://i.imgur.com/J1YaQlH.png
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 13th December 2021 at 01:24.
LoRd_MuldeR is offline   Reply With Quote
Old 19th January 2022, 17:27   #2  |  Link
xofaho
Registered User
 
Join Date: Jan 2022
Location: USA
Posts: 8
As I know, the only way to enable glass effect in Windows is to install a third-party software, but Idk which exactly.
xofaho is offline   Reply With Quote
Old 23rd January 2022, 23:02   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,222
Please note that this question is not about "third-party software" to modify the look of Windows 11 itself or that of someone else's software.

It is about getting Windows 11 to correctly render my software with the "smoked glass" effect, just as a vanilla Windows 11 already does in the Start menu or in the "Settings" app.

For now, I have disabled DwmEnableBlurBehindWindow() on Windows 11, which is better than a fully transparent background...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.