Created
May 15, 2014 02:41
-
-
Save sergiogarciadev/444c6acb48b8420f60cc to your computer and use it in GitHub Desktop.
A form that can't be clicked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
const int GWL_EXSTYLE = -20; | |
const int WS_EX_TRANSPARENT = 0x20; | |
[DllImport("user32.dll", CharSet=CharSet.Auto)] | |
extern static int GetWindowLong(IntPtr hWnd, int nIndex); | |
[DllImport("user32.dll", CharSet = CharSet.Auto)] | |
extern static int SetWindowLong(IntPtr hWnd, int nIndex, int nStyle); | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
var style = GetWindowLong(this.Handle, GWL_EXSTYLE); | |
var newStyle = style | WS_EX_TRANSPARENT; | |
SetWindowLong(this.Handle, GWL_EXSTYLE, newStyle); | |
} | |
private void timer1_Tick(object sender, EventArgs e) | |
{ | |
this.BringToFront(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment