C # implement Windows 7 Aero frosted glass using WinForm

Source: Internet
Author: User

After the Vista system, Microsoft provided the Aero matte effect for the form program, such. C # is used as an example.
How can we achieve this matte effect?

 

Code:

 System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; System.Reflection; System.Runtime.InteropServices; WindowsFormsApplication1{     partial  Form1 : Form    {                [StructLayout(LayoutKind.Sequential)]          MARGINS        {              Left;              Right;              Top;              Bottom;        }                [DllImport("", PreserveSig = )]           DwmExtendFrameIntoClientArea(IntPtr hwnd,  MARGINS        margins);                [DllImport("", PreserveSig = )]           DwmIsCompositionEnabled();                   OnLoad(EventArgs e)        {             (DwmIsCompositionEnabled())            {                MARGINS margins =  MARGINS();                margins.Right = margins.Left = margins.Top = margins.Bottom =        .Width + .Height;                DwmExtendFrameIntoClientArea(.Handle,  margins);            }            .OnLoad(e);        }                   OnPaintBackground(PaintEventArgs e)        {            .OnPaintBackground(e);             (DwmIsCompositionEnabled())            {                e.Graphics.Clear(Color.Black);            }        }         Form1()        {            InitializeComponent();        }    }}

 

 

 

In this example, the system's dwmapi. dll is called.


Dwmapi. dll is a dynamic link library of the Microsoft Desktop Window Manager API (the common interface of the Desktop Window Manager DWM). It is a normal file and is mainly used as an api for Desktop effect.

 

DWM is a new interface that provides DWM interfaces in all Windows Vista versions except Windows Vista Home Basic. Therefore, this effect can only be used in systems after Vista.

Related Article

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.