代码之家  ›  专栏  ›  技术社区  ›  TecMan

在crean之后为WinForms窗体设置CS_DROPSHADOW会导致其他窗体出现双重阴影

  •  1
  • TecMan  · 技术社区  · 7 年前

    在2012年我写信给 this thread

    System.Runtime.InteropServices.HandleRef myHandleRef = new System.Runtime.InteropServices.HandleRef(this, this.Handle);
    int myStyle = NativeMethods.GetClassLongPtr(myHandleRef, iGNativeMethods.CS_DROPSHADOW).ToInt32();
    if (hasShadow)
        myStyle |= NativeMethods.CS_DROPSHADOW;
    else
        myStyle &= ~NativeMethods.CS_DROPSHADOW;
    NativeMethods.SetClassLong(myHandleRef, NativeMethods.GCL_STYLE, new IntPtr(myStyle));
    

    enter image description here

    Form myForm = new Form();
    myForm.Show();
    

    有没有另一种方法可以将CS_DROPSHADOW样式应用于现有表单而不会产生这种奇怪的副作用?

    0 回复  |  直到 7 年前
    推荐文章