c#


Making a transparent/Click-throughable VB.net form clickable with a toggle


So I was working on a transparent add-on VB.net program that will be clickable only if you click shift. E.g. It will just stay there but clicks will go through it unless I hold shift f.e
I saw this and tested the codes,
VB.net Click through form
However I tried to change some controls but none are able to give me a kind of "toggle". Any clue of what I can fix for it?
Answers in C# are welcome as well as I can program C# instead if it is not do-able in VB
Edit: Code I have been trying to use is this
Imports System.Runtime.InteropServices
Public Class Form1
Private InitialStyle As Integer
Dim PercentVisible As Decimal
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitialStyle = GetWindowLong(Me.Handle, -20)
PercentVisible = 0.8
SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20)
SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2)
Me.BackColor = Color.Red
Me.TopMost = True
End Sub
<DllImport("user32.dll", EntryPoint:="GetWindowLong")> Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="SetWindowLong")> Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="SetLayeredWindowAttributes")> Public Shared Function SetLayeredWindowAttributes(ByVal hWnd As IntPtr, ByVal crKey As Integer, ByVal alpha As Byte, ByVal dwFlags As Integer) As Boolean
End Function
End Class
I found the color to make all the difference; afaik this is a legacy bug/feature we can make use of.
Here is a minimal example:
public Form1()
{
InitializeComponent();
BackColor = Color.FromArgb(123,234,34);
TransparencyKey = BackColor;
Text = "Click Me!";
KeyPreview = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Shift)
{
BackColor = Color.Fuchsia;
TransparencyKey = BackColor;
Text = "Click Through!";
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
BackColor = Color.FromArgb(123,234,34);
TransparencyKey = BackColor;
Text = "Click Me!";
}

Related Links

extract numbers and alpha into two strings
Adding label to menustrip
Splitting string and performing calculations from delimited string tokens C#
Interface: Declaring a class with inherited interface
C# login using SQL Server database not working [closed]
How to export a random entry in a datbase to a word table using C#
Circular references preventing serialization of object graph
Logging Window in MTA thread: Access Violation
DataSet does not support System.Nullable<> exception in c#
Reading xml which has been converted from a recordset
how to get response value from callback function wp7
Getting duplicate key values from SQL Exception
WinRT how do you dynamically add a Triangle to a canvas
How to use Group By, Sum, and Contains in a single LINQ query?
NHibernate QueryOver Alias Issue
MEF composition import issue when using specific interface

Categories

HOME
classification
virtual-machine
display
bigtable
opencv4android
query-string
swap
jquery-select2
virtualhost
revit-api
runtime
mongoimport
dynamics-crm-2011
captcha
cakephp-2.0
fastreport
logstash-configuration
luis
ibatis
android-actionbar
caldav
url-parameters
datazen-server
aws-iot
uipath
ppp
datastax-enterprise
windows-mobile
orgchart
workflow-foundation
emr
sphinx4
ocl
concrete5
undo
schedule
andengine
foxpro
akamai
kubectl
tunnel
iterm2
instances
scalamock
armadillo
fisheye
taleo
niagara-ax
synchronized
e4
androiddesignsupport
wicketstuff
was
msiexec
vertex-shader
jira-agile
recurring
hfp
nsoperationqueue
python-rq
pebble-js
wizard
dday
web-performance
producer-consumer
azure-mobile-app
minko
beagleboard
douglas-peucker
report-builder2.0
tigase
powershell-v1.0
code-smell
traceur
mahara
lastinsertid
objectdatasource
wpa
backbone-views
symbian3
gwt2
django-tinymce
m3u
netbiscuits
log-shipping
peoplepicker
cryptolicensing
netbeans7.0
excellibrary

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile