| 1. | This first option requires no custom coding on your part. Set the form's TransparencyKey to some odd ball color you'd never use anywhere on the form. The TransparencyKey designation tells windows not to repaint anything on that form that has this color which has the end affect of punching a hole in your form. So, all of the mouse events run right through your form as if it were never there. Controls on the form, however, are not affected. They will still work as normal. If you opt to set a control's backcolor to your TransparencyKey color, they to will have a transparent background. The main problem with this is that the control no longer reacts properly for focus, certain mouse events, and click events. In order to get around this, you'll have to put something in the MouseMove event of each control and constantly set its backcolor to some other fixed color when over the control and back to the TransparencyKey on MouseLeave. |
private bool FormMouseDown=false;
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (FormMouseDown==true) { return; }
FormMouseDown = true;
this.Visible = false;
WinApi.Mouse.SendDoubleClick();
Thread.Sleep(250);
this.Visible = true;
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
FormMouseDown=false;
}
|
using System;
using System.Runtime.InteropServices;
namespace WinApi
{
public class Mouse
{
[DllImport("user32.dll")]
private static extern void mouse_event(UInt32 dwFlags,UInt32 dx,UInt32 dy,UInt32 dwData,IntPtr dwExtraInfo);
private const UInt32 MouseEventLeftDown = 0x0002;
private const UInt32 MouseEventLeftUp = 0x0004;
public static void SendDoubleClick()
{
mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
}
}
}
|