Code
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Reflection;usingSystem.Runtime.InteropServices;//referencing DLL declarationsnamespacewindowsformsapplication1{ Public Partial classForm1:form {//DLL Declaration[StructLayout (layoutkind.sequential)] Public structMARGINS { Public intLeft ; Public intRight ; Public intTop; Public intBottom; } //DLL Declaration[DllImport ("Dwmapi.dll", PreserveSig =false)] Static extern voidDwmExtendFrameIntoClientArea (INTPTR hwnd,refMARGINS MARGINS); //DLL Declaration[DllImport ("Dwmapi.dll", PreserveSig =false)] Static extern BOOLdwmiscompositionenabled (); //Add code directly protected Override voidOnLoad (EventArgs e) {if(dwmiscompositionenabled ()) {MARGINS MARGINS=NewMARGINS (); Margins. Right= margins. left = margins. Top = margins. Bottom = This. Width + This. Height; DwmExtendFrameIntoClientArea ( This. Handle,refmargins); } Base. OnLoad (e); } //Add code directly protected Override voidOnPaintBackground (PaintEventArgs e) {Base. OnPaintBackground (e); if(dwmiscompositionenabled ()) {e.graphics.clear (color.black); } } PublicForm1 () {InitializeComponent (); } }}
The implementation of this effect is mainly called the Dwmapi.dll of the system.
Dwmapi.dll is a dynamic-link library of the Microsoft Desktop Window Manager API (the common interface of the desktop Windows Manager dwm), a normal file that is primarily used as an API for desktop effects.
The DWM is a new interface that provides the DWM interface in all versions of Windows Vista except Windows Vista Home Basic. So this effect can only be used in a system after vista.
C # WinForm implements Windows 7 Aero frosted glass effect