Почему я могу кликнуть по моей форме? - PullRequest
2 голосов
/ 08 января 2011

Я экспериментирую и пытаюсь выяснить 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);

    }
}

1 Ответ

0 голосов
/ 08 января 2011

Это потому, что у вас есть

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

Удаление линии с прозрачностьюЭто также происходит в WindowsForms.Я думаю, что это дизайн, а не ошибка.

...