C# WinForm实现Win7 Aero磨砂效果
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
static extern bool DwmIsCompositionEnabled(); //Dll 导入 DwmApi
protected override void OnLoad(EventArgs e)
{
//如果启用Aero
if (DwmIsCompositionEnabled())
{
MARGINS m = new MARGINS();
m.Right = -1; //设为负数,则全窗体透明
DwmExtendFrameIntoClientArea(this.Handle, ref m); //开启全窗体透明效果
}
base.OnLoad(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
if (DwmIsCompositionEnabled())
{
e.Graphics.Clear(Color.Black); //将窗体用黑色填充(Dwm 会把黑色视为透明区域)
}
}
dwmapi.dll,什么地方有?
elwinpan 发表于 2017-4-10 11:08
dwmapi.dll,什么地方有?
windows 系统自带的
页:
[1]