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

IZENDA report on ASP.NET MVC application for binary image data convertion
ASP.NET MVC - Displaying the Same View again with extra information based on a radio-button selection
DataGridViewComboBoxColumn value and add items as option
powerbuilder datawindow report in asp.net MVC 5
C# Amadeus sending ping request
ASP.NET Core: Custom IFileProvider prevents default IFileProvider from working
Two csProj assemblies with “same name” causing issues
InitializationException in Unity Firebase
Using TLS 1.2 with C#.Net Winform App and SQL Server 2008
DateTime.Parse issue on 1st of March 2017
How do I set location of button to be top right of screen? [closed]
Single function classes (named as verbs)
How do I add time together?
How to avoid sql strings using linq (WPF project)
Accessing the microphone level in Windows with C#
Load XAML at runtime, but control CLR-type resolving?

Categories

HOME
joomla
redux
wifi
webvr
apache-storm
gap-system
salesforce-lightning
sugarcrm
comments
hibernate-mapping
doctrine2
promotions
email-attachments
virtualenv
comma
opendaylight
web-testing
web-worker
k-means
orange
google-street-view
draw2d
glibc
include-path
poisson
sha
aws-certificate-manager
rancher
gulp-jshint
log4net-configuration
visual-prolog
unity3d-5
snapkit
traitsui
leaderboard
respect-validation
lex
cowboy
pyexcel
gradlew
django-cors-headers
chrome-custom-tabs
import.io
lucee
xamarin-test-cloud
sharing
lattice
copy-constructor
firebase-polymer
toggleclass
mavlink
dimensionality-reduction
dbi
ldd
key-value-store
jmh
apache2-module
google-finance-api
overlapping
mojolicious
vanilla-forums
eaaccessory
clearquest
cl.exe
conkeror
attiny
chunks
gnip
dotcmis
xpand
satisfiability
xps
node-mongodb-native
kuka-krl
ojb
oc4j
windows-scheduler
magicsuggest
pageload
generator-expression
metapost
mail-gem
mysql-connector
visual-leak-detector
cgaffinetransform
backlight
symfony-1.2
service-layer
simultaneous
iphone-maps
database-agnostic
silverlight-2.0
focus-stealing
retrospectiva
bootstrap-protocol
expander
paperless

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