How to get policy value after set?

D.D.K-2637 966 Reputation points
2024-10-24T08:01:21.67+00:00

Hi,

Is there a way to check if the state has been assigned?

I tried this but the return value of v=11

DWMNCRENDERINGPOLICY v;
auto k = DwmGetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &v, 4); <- v return 11.

BOOL v;
auto k = DwmGetWindowAttribute(hwnd, DWMWA_NCRENDERING_ENABLED, &v, sizeof(v)); <-OK but v return 0;

I thought it would return DWMNCRP_ENABLED but it doesn't?

Am I calling it the wrong way or is there any way to check its current state (apparently the style is still showing but i don't know how to check it yet)?

Thanks you!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,651 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,758 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 85,806 Reputation points
    2024-10-24T09:07:11.2333333+00:00

    This works for me (Windows 10 22H2) :

    					BOOL bRendering = FALSE;
    					// returns TRUE
    					HRESULT hr = DwmGetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &bRendering, sizeof(bRendering));
    
    					// Disable
    					DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED;					
    					hr = DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
    
    					// returns FALSE
    					hr = DwmGetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &bRendering, sizeof(bRendering));
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.