2011-01-07 4 views
2

나는 DWM과 Windows Aero를 시험하고 실험하려고합니다. 지금까지는 폼이 두꺼운 부분을 클릭 할 때 마우스 클릭이 제대로 진행되고 멈추는 방법을 찾을 수 없다는 이상한 이유를 제외하고는 거의 모든 것을 가지고 있다고 생각합니다. 투명도와내 양식을 클릭하면 왜 나옵니까?

this.BackColor = Color.Magenta; 
this.TransparencyKey = Color.Magenta; 

제거 라인을 가지고 있기 때문이다

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace WindowsFormsApplication1 
{ 
    public partial class Form1 : Form 
    { 
     int en; 
     public Form1() 
     { 
      InitializeComponent(); 
      DwmIsCompositionEnabled(ref en); 
      if (en > 0 && System.Environment.OSVersion.Version.Major >= 6) 
      { 
       en = 0; 
       MARGINS mg = new MARGINS(); 
       mg.m_Buttom = 0; 
       mg.m_Left = 0; 
       mg.m_Right = 0; 
       mg.m_Top = 25; 
       DwmExtendFrameIntoClientArea(this.Handle, ref mg); 
       this.BackColor = Color.Magenta; 
       this.TransparencyKey = Color.Magenta; 
      } 
     } 
     public struct MARGINS 
     { 
      public int m_Left; 
      public int m_Right; 
      public int m_Top; 
      public int m_Buttom; 
     } 
     [System.Runtime.InteropServices.DllImport("dwmapi.dll")] 
     public extern static int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margin); 
     [System.Runtime.InteropServices.DllImport("dwmapi.dll")] 
     public extern static int DwmIsCompositionEnabled(ref int en); 

    } 
} 

답변

0

. 이것은 WindowsForms에서도 발생합니다. 버그가 아니라 디자인이라고 생각합니다.

+0

문제는 양식을 확장하고 Aero를 사용하여이를 수행해야한다는 것입니다.이 작업을 수행 한 유일한 방법은 투명성입니다. – Sean

+1

@Sean : 글래스를 윈도우로 확장하는 것은 레이어 된 (WS_EX_LAYERED 스타일) 윈도우에서만 작동하며, TransparencyKey의 부작용 중 하나는 윈도우를 레이어 화하는 것입니다. 창을 계층화하는 또 다른 방법을 찾아야합니다. –