简体   繁体   中英

Bypass mouse events for Winforms using c#

I have loaded a Winform using following code, with semi-transparent effect.

    frmTest frm=new frmTest();
    frm.Opacity = 0.051;
    frm.Left = 0;
    frm.Top = 0;
    frm.Width= Screen.PrimaryScreen.Bounds.Width;
    frm.Height= Screen.PrimaryScreen.Bounds.Height;
    frm.Show();

Now I'm looking for some way to bypass my form from responding to mouse clicks. For example, the form displays over the desktop with semi-transparent, the user clicks on form, and the desktop should get that mouse click instead of my form. My form only need to be visible to user, but no collision with it.

I tried disabling my form, but having no idea about how to pass the mouse event to desktop or other program below my form. Can someone please point me in right direction to solve this?

Maybe something like this :

  1. Capture all Mouse event
  2. Hide your form frm.Visible = false;
  3. Fire the same mouse event as the one captured (see How can I simulate a mouse click at a certain position on the screen? )
  4. Show your form frm.Visible = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM