Disable win7 glass Effect

Source: Internet
Author: User

Disable win7 glass Effect

From: blog.csdn.net/windows_nt

Dwmenablecomposition: Call this function to disable the glass effect of the entire system.

Dwmsetwindowattribute calls this function to close the glass effect of a window.

Only applicable to XP and later systems, because the XP system does not have the Link Library dwmapi. dll.

 

Run the following code in the bool cxxapp: initinstance () of the program to call

 

Disable system glass Effect

Typedef hresult (_ stdcall * lpfndwmiscompositionenabled) (bool * State );

Typedef hresult (_ stdcall * lpfndwmenablecomposition) (uint setstate );
Lpfndwmiscompositionenabled lpfnisenabled = 0;
Lpfndwmenablecomposition lpfnsetenable = 0;
 
Hmodule library =: loadlibrary (_ T ("dwmapi. dll "));
Bool result = 0;
 
If (0! = Library)
{
Lpfnisenabled = (lpfndwmiscompositionenabled) getprocaddress (library, "dwmiscompositionenabled ");
Lpfnsetenable = (lpfndwmenablecomposition) getprocaddress (library, "dwmenablecomposition ");

If (lpfnisenabled! = 0)
{
Bool enabled = false;
Result = succeeded (lpfnisenabled (& enabled) & enabled;
}

If (Result & lpfnsetenable! = 0)
{
Result = succeeded (lpfnsetenable (0/* disable */));
}

Verify (: freelibrary (Library ));
}

 

Close the glass effect of a window
If the compiler is a version later than vs2008, the code is very simple. You only need to add the following code in the window initialization:

Dwmncrenderingpolicy NCRP = dwmncrp_disabled;
Dwmsetwindowattribute (getsafehwnd (), dwmwa_ncrendering_policy, & NCRP, sizeof (NCRP ));

Include # include <dwmapi. h>

If the compiling environment is lower than vs2008 and there is no Vista SDK, the following code is used:

Since there is no dwmapi. h file in the compiling environment, you must add the following definitions.

// Close the glass effect of an application. This code must be placed after the m_pmainwnd pointer is assigned a value and the following code is called:
Enum dwm?wattri=
{
Dwmwa_ncrendering_enabled = 1, // [get] is non-client rendering enabled/disabled
Dwmwa_ncrendering_policy, // [set] non-client rendering Policy
Dwmwa_transitions_forcedisabled, // [set] potentially enable/forcibly disable transitions
Dwmwa_allow_ncpaint, // [set] Allow contents rendered in the non-client area to be visible on the DWM-drawn frame.
Dwmwa_caption_button_bounds, // [get] bounds of the caption button area in window-relative space.
Dwmwa_nonclient_rtl_layout, // [set] is non-client content RTL mirrored
Dwmwa_force_iconic_representation, // [set] force this window to display iconic thumbnails.
Dwmwa_flip3d_policy, // [set] designates how flip3d will treat the window.
Dwmwa_extended_frame_bounds, // [get] gets the extended frame bounds rectangle in screen space
Dwmwa_last
};
Typedef Enum _ dwmncrenderingpolicy {
Dwmncrp_usewindowstyle,
Dwmncrp_disabled,
Dwmncrp_enabled,
Dwmncrp_last
} Dwmncrenderingpolicy;

Then we can get the function of removing the glass effect (dwmset?wattri=) in the dynamic link library and then execute this function.
Typedef hresult (winapi * tmpfun) (hwnd, DWORD, lpcvoid, DWORD );
Hmodule library =: loadlibrary ("dwmapi. dll ");

Tmpfun dwmset?wattributeex;
If (0! = Library)
{
Dwmsetaskwattributeex = (tmpfun): getprocaddress (library,
"Dwmsetaskwattribute ");
If (dwmsetwindowattributeex)
{
Dwmncrenderingpolicy NCRP = dwmncrp_disabled;
(* Dwmsetwindowattributeex) (m_pmainwnd-> getsafehwnd (), dwmwa_ncrendering_policy, & NCRP, sizeof (NCRP ));

}
Verify (: freelibrary (Library ));
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.