1

I am working on an on-screen cursor highlighting project for my needs C# windows forms and I'm stuck with a problem, I already made my form transparent so I could draw a filled ellipse on the form and make the form follow my cursor, the only problem here is that I can't click anything with this white ellipse following my cursor. If somebody can tell me how to make the ellipse pass my clicks it would help so much

The thing is that I tried to search for answers, but I found other things that didn't help me.

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);
    }
}
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Welcome to Stack Overflow. I'm not entirely certain what you're trying to do, [but I suspect it might be this](https://stackoverflow.com/questions/5102982/winforms-equivalent-of-wpfs-ishittestvisible). – 15ee8f99-57ff-4f92-890c-b56153 Jun 03 '19 at 14:27
  • Thanks, I think you didn't understand me, here, I made some screenshots: https://imgur.com/a/UUkxqS4 – Tommy Izmerly Jun 03 '19 at 14:42
  • The screenshots don't explain anything. I see Visual Studio with a yellow circle. That doesn't help me understand your intent. Do you understand the answer I linked? Do you understand what that code is doing? – 15ee8f99-57ff-4f92-890c-b56153 Jun 03 '19 at 14:43
  • I saw the answer you linked but I had difficulties with understanding what it supposed to do, it's just my bad newbie skills – Tommy Izmerly Jun 03 '19 at 14:46
  • There's nothing wrong with being a newbie. That code illustrates how to implement transparency to mouse events in windows forms. – 15ee8f99-57ff-4f92-890c-b56153 Jun 03 '19 at 14:47
  • Thank you for translating this to me. I'll try it and then come back if something happens – Tommy Izmerly Jun 03 '19 at 14:51
  • That code is not a solution to your problem. You must understand what that code is doing and apply it to your problem. It won't be very simple. You have chosen a difficult project for a beginner. – 15ee8f99-57ff-4f92-890c-b56153 Jun 03 '19 at 14:52
  • When pasting the code, only form objects are clickable through the shape, other than that. when I go to objects outside the form. it doesn't work – Tommy Izmerly Jun 03 '19 at 15:25
  • That's correct. As I said, that code as it stands is not a solution to your problem. It illustrates how to make something in WinForms transparent to mouse clicks. You need to figure out how to do the same with a Form, so the mouse clicks are handled by a window behind it belonging to a different process. I think this is probably doable. I don't have that code written, and unfortunately I have a busy day today. – 15ee8f99-57ff-4f92-890c-b56153 Jun 03 '19 at 15:29

0 Answers0