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

How to get request culture from IStringLocalizer implementation
Microsoft Enterprise Library- ExecuteReader returns closed Datarow
WCF Response - Serialization of lists in response
Dependency Injection broken after adding Owin, no parameterless constructor defined for this object
Can't solve an exercise from a book [closed]
Loading Microsoft Reports the proper way
Looping through Dictionary items in iTextsharp
How to copy contents of one text file to another by character?
c# Change the format of a string
WinForms Livecharts Chart Title
Downloading while processing
How do I reference a database table in LINQ(C#) and return it as a JsonResult
mongodb c# pusheach position subdocument
Assign UserId to my child entity results in a 2n UserId1 column in the sql table
Mono.Cecil: Insert a log statement in method's beginning
Passing values from c# to actionscript 3 and crossdomain questions

Categories

HOME
skype-for-business
youtube-api
ssms
kendo-ui-angular2
sip
salesforce
spss
powerquery
procmon
cdn
sitemap
restheart
web-testing
k-means
pylint
webgl-earth
klipfolio
smali
struts
smart-device
workflow-foundation
multiple-inheritance
blockly
ng2-bootstrap
leaderboard
maven-2
word-wrap
iterm2
ngrok
server-side-swift
socketcluster
irr
qt-quick
amazon-rds-aurora
head
mef
line-endings
rivets.js
confluent
audio-fingerprinting
sharpssh
tsc
robotc
jira-agile
require-handlebars
deck.js
cherry-pick
nugetgallery
code-translation
jsondoc
dday
sdkman
roslyn-code-analysis
hexagonal-tiles
service-broker
applinks
sony-xperia
pysvn
aiff
jsonmodel
angular-file-upload
twitter-finagle
debuggervisualizer
dateadd
traceur
connections
infor-eam
logo-lang
ekevent
xml-validation
ojb
violation
qgraphicsscene
forward-declaration
google-checkout
removeall
expresso-store
big-endian
xcode4.6.3
dancer
socketasynceventargs
project-files
windows-xp-embedded
lightopenid
text-manipulation
pitch-shifting
dongle
mysql-pconnect
calendarextender
mdd
dojox.gfx
expander
scalable

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