如何使点击以透明形式通过形状

时间:2019-06-03 14:18:15

标签: c# forms pointers cursor

我正在根据自己的需要在屏幕上突出显示光标项目 C#Windows窗体,但我遇到了问题,我已经使窗体透明了,因此我可以在窗体上绘制一个填充的椭圆并使窗体跟随光标,这里唯一的问题是我无法对此单击任何内容白色椭圆形跟随我的光标。 如果有人能告诉我如何使椭圆通过点击,那将有很大帮助

问题是我试图寻找答案,但是我发现其他对我没有帮助的事情。

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();

    }

    private void Form2_Load(object sender, EventArgs e)
    {
        timer1.Start();
        this.AllowTransparency = true;
        this.Opacity = 50;
        this.TopMost = true;
    }

    private void Timer1_Tick(object sender, EventArgs e)
    {
        Point pt = Cursor.Position;
        pt.Offset(-(this.Width / 2), -(this.Height / 2));
        this.Location = pt;
    }

    private void Form2_Paint(object sender, PaintEventArgs e)
    {
        SolidBrush solidBrush = new SolidBrush(
        Color.FromArgb(255, 255, 0));
        e.Graphics.FillEllipse(solidBrush, (Width - 60) / 2, (Height - 60) / 2, 60, 60);
    }
}

0 个答案:

没有答案
相关问题