C # WinForm implements Windows 7 Aero frosted glass effect

Source: Internet
Author: User

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

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.