The final version(includes the fix for int to byte conversion).
bool _transparent;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) | WS_EX_LAYERED);
if (e.Button == MouseButtons.Right)
{
_transparent = !_transparent;
byte alpha = (byte)(_transparent ? 10 : 255);
SetLayeredWindowAttributes(Handle, 0, alpha, LWA_ALPHA);
}
}