2
我正在試驗並試圖找出DWM和Windows Aero。到目前爲止,我想我幾乎都有它,除了一些奇怪的原因之外,當我單擊窗體的較厚部分時,我的點擊就通過它,並且我無法弄清楚如何阻止它。爲什麼我可以點擊我的表單?
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);
}
}
問題是我需要擴展我的表單並使用Aero來這樣做,而且我發現要做到這一點的唯一方法就是透明化。 – Sean 2011-01-07 22:42:42