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

MVC3 C# Custom HtmlHelper for input with validation, both client and server side
Random GLU error 100155: tesselation coordinate too large
Dynamically created textbox values losses when i click the button
MVP: Multiple views/presenters for one complex form (winforms)?
Change linkbutton color
IE isn't showing my innerHTML that I dynamically add to my select control via ajax call. Firefox is ok
How to upload a file from server filesystem to SQL server
C#: Running a transaction on SQL Server 2008 via ADO.NET
installshield projects runtime error
Update datatables using relation
NServiceBus RavenDB Saga persister ignores JsonIgnoreAttribute
Get an instance of TabItem's ContentTemplate
How can I format numbers to have the same number of digits?
Dangling thread in wcf callback
FormView ItemUpdating with Checkbox
How to use an Items Collection Editor on a custom UserControl (.Net 4, Winforms)?

Categories

HOME
airflow
classification
cxf
wifi
snappy
aix
phantomjs
gap-system
confluence-rest-api
css-selectors
hibernate-mapping
schema
install
vsixmanifest
promotions
software-collections
mamp
mbed
repeater
lambda-calculus
box2d
jsfiddle
brightway
template10
smooth-scrolling
windows-phone
virtuemart
google-calendar-api3
hapijs
single-page-application
google-drive-android-api
sha
ckeditor4.x
aws-certificate-manager
nsopenpanel
akavache
visual-studio-community
stack-trace
bytebuffer
jms-topic
jbossfuse
keil
directions
visual-prolog
http-proxy
cache-control
maven-2
multi-user
matrix-multiplication
redhat-brms
libconfig
nscollectionview
blueimp
ssdp
tapply
directadmin
codepen
risc
amazon-fire-tv
riemann
jenkins-docker
petapoco
qudpsocket
settext
git-cherry-pick
db2-zos
archiva
nugetgallery
videoview
app-data
imageicon
php-gd
page-flipping
properties-file
android-networking
grails-3.0.9
mergecursor
bungeecord
launcher
illegalargumentexception
xmlserializer
lwuit
ios-enterprise
step
amzi-prolog
telerik-appbuilder
slimscroll
mongoid4
google-oauth-java-client
aspnet-compiler
uikit-dynamics
vline
rbm
blackberry-eclipse-plugin
django-admin-tools
socketasynceventargs
pinchzoom
cgaffinetransform
mcpd
opendir
overlays
norton
llblgen
azure-appfabric
datarelation
nyromodal
mysql-pconnect
helios
time-management
office-2003

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App