.net - Glass Effect in C # 2.0 Applications

How can I use Vista or Mac OS X-style glass effects for Windows form applications in .net 2.0?

+3
source share
3 answers

This is done by interacting with the Vista DWM (Desktop Window Manager) API.

For example, import these functions:

[DllImport("dwmapi.dll")]
static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);


[StructLayout(LayoutKind.Sequential)]
struct Margins
{
    public int cxLeftWidth;
    public int cxRightWidth;
    public int cyTopHeight;
    public int cyBottomHeight;
}

Then you can use this to “pull” the glass from the top of the window down to the client area:

GlassMargins.Top = 40;
GlassMargins.Left = 0;
GlassMargins.Right = 0;
GlassMargins.Bottom = 0;

DwmExtendFrameIntoClientArea(this.Handle, ref GlassMargins);

Here you can go ahead and do other things, such as draw text or images on glass, or place controls on it, such as an Office 2007-style application button.

+4
source

Vista Aero DWM. . Vista, .

, DwmExtendFrameIntoClientArea, Internet Explorer . , interop, ( http://pinvoke.net).

+2

Source: https://habr.com/ru/post/1710438/


All Articles