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

Why does Visual Studio create double closing brackets for C#6 interpolated strings?
Why does XNA upgrade VS 2010 from v. 10 to v. 11?
Download All Blobs from single Azure Container
Telerik HTML5 Report Viewer - Error loading the report viewer's templates
Extracting image from a slide of a .pptx
How to sort in EF parents by number of children of children of children?
Fetch Data from database to Fullcalendar.io using Json
How can I handle button Click in XAML?
Binding a singleton list to a list view
Uploading documents from Amazon S3 to CloudSearch using .NET SDK
Import multiple XML files into Excel
Twilio rest api error code 21612
Generate list with random numbers. Sort and total sum
“Windows.UI.Xaml.Markup.XamlParse.Exception”
Am I using ContinueWith correctly?
Load multiple methods from dll at runtime C#

Categories

HOME
asp.net
grizzly
botframework
teradata
system-calls
oracle-sqldeveloper
magento-1.9.2.1
azure-resource-manager
hiveql
mailchimp
localhost
gnuradio
sequence
distinct
chef-recipe
expo
comma
aggregate
exchange-transport-agents
ibatis
project-reactor
openoffice-basic
rvm
prepros
pumping-lemma
ps
sasl
knapsack-problem
ballerinalang
gulp-jshint
angular2-changedetection
selenium3
edsdk
foxpro
tikz
sampling
dom4j
cocoa-scripting
console.readline
wicket-tester
ape-phylo
smooth-streaming
python-venv
ocpjp
stream-socket-client
visualizer
playframework-1.x
openpgp.js
boost-regex
xamarin-test-cloud
scriptengine
csc
git-cherry-pick
usps
sdkman
database-project
edgar
updating
borland-c++
jad
teamstudio-unplugged
alpha-beta-pruning
crystal-reports-7
yosemite
triplestore
angular-file-upload
django-tests
sigma-grid-control
nop
ojb
violation
urlfetch
moonscript
inflate
wpml
derived-class
bash4
optimistic-concurrency
socketasynceventargs
animationdrawable
eeprom
quazip
cinder
excellibrary
p4.net
newspeak
calendarextender
disk-based
cstring
memory-consumption

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