Hello, @trance . I have reproduced the behavior in Windows11 and it does work well in Window 7 and Window 10. I'm consulting my senior for the behavior. Thank You.
Failed to disable Peek Preview in Windows 11
Hi, everyone!
To implement some custom fetatures I need to disable peek preview for the window. So I call DwmSetWindowAttribute
with DWMWA_DISALLOW_PEEK
set to True
to disallow peek preview.
It works well in Win7 and Win10 but in my newest Win11 machine, it sill shows peek preview when the mouse hovers over the window's thumbnail in the taskbar.
And I use a demo from VS2019 to reproduce this bug and still it works well in Window 7 and Window 10, but not in Windows 11.
I also read the SDK document and I don't find changes relevant to this behavior. Did I misuse this interface? If you know the right way to disable it, let me know plz~~
Steps to reproduce the bug
- Open Visual Studio 2019 and New C++ Desktop Project.
- With a built-in demo, disable peek preview with
DwmSetWindowAttribute
#include <dwmapi.h> .... // built-in demo .... BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // ****************** to reproduce this bug ****************** BOOL disallow_peek = TRUE; DwmSetWindowAttribute(hWnd, DWMWA_DISALLOW_PEEK, &disallow_peek, sizeof(disallow_peek)); // ****************** to reproduce this bug ****************** return TRUE; }
- Add link dependency dwmapi.lib
- Compile and Run
- It still shows peek preview in Windows 11 but not in Windows 10/7.
Expected behavior
No peek preview in Windows 11(22000.829)
2 answers
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,726 Reputation points Microsoft Vendor
2022-07-21T05:03:55.793+00:00 -
Limitless Technology 39,816 Reputation points
2022-07-21T13:47:13.727+00:00 Hi,
According to this document the function should still work in Windows 11:
https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute
Have you downloaded the latest dwmapi.lib to ensure that this is not the issue?
------------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--