我做了一个窗体,并在其中扩展了玻璃,如下图所示。但是,当我移动窗口,使其不能在屏幕上全部显示时,玻璃渲染在我将它移回后错误: 玻璃不是正确的
如何处理此问题,以便窗口呈现正确?
这是我的代码:
[DllImport("dwmapi.dll")]
private static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins mg);
[DllImport("dwmapi.dll")]
private static extern void DwmIsCompositionEnabled(out bool enabled);
public struct Margins{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
private void Form1_Shown(object sender, EventArgs e) {
this.CreateGraphics().FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, this.ClientSize.Height - 32, this.ClientSize.Width, 32));
bool isGlassEnabled = false;
Margins margin;
margin.Top = 0;
margin.Left = 0;
margin.Bottom = 32;
margin.Right = 0;
DwmIsCompositionEnabled(out isGlassEnabled);
if (isGlassEnabled) {
DwmExtendFrameIntoClientArea(this.Handle, ref margin);
}
}
如何知道如果它不可见? – Gabe
不确定你的意思......你是说如果你移动窗口越过屏幕边缘再返回,那么玻璃已经在窗口与屏幕边缘相交的部分消失了? – series0ne
P.S.我过去曾多次使用过玻璃。在Google中搜索Daniel Moth和Glass ...他似乎是一位具有玻璃效果的古茹! – series0ne