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

What is the fastest parser generator tool for C# output? [closed]
Process Management in .NET
Issue with self-many to many join in Fluent NHibernate
LINQ-to-XML: Selecting specific node value
OnClient Click javascript using Freetextbox
Please help on choosing the right arhitecture of n-tier web application
Read Excel using c# .net Issue
Is passing null in to a method acceptable
Howto parse string like '/aaa/bbb/ccc/ddd'?
Linq Match Array to List?
Can I view the runtime structure of a dynamic in .Net?
Is there a way to simplify this linq
how to get Dictionary<int , ClassA> from Regex.Split
I need an analyzing tool for C#
Regex to Match a String Followed By a Another Word
C++ Equivalent of Pages.Add() in Visual Studio Windows Forms

Categories

HOME
logging
stata
stanford-nlp
intellij-idea
mobile
virtual-machine
salesforce
ssh
openacc
aix
livecharts
crm
x509certificate
xss
hibernate-mapping
sequence
virtualhost
rethinkdb
yacc
activejdbc
core-data
sha1
luis
md2
orange
printf
project-structure
descriptor
libxml2
cqlsh
andengine
foxpro
urhosharp
slim-lang
webmock
aspose.pdf
observer-pattern
bzip2
mtm
flume-ng
spring-webflow-2
infovis
openxava
audio-fingerprinting
photoshop-script
try-catch-finally
cardview
google-scholar
toggleclass
sprockets
objectify
nimbus
3d-rendering
bbedit
periodic-processing
abstract
overlapping
jcomponent
event-tracking
taverna
roslyn-code-analysis
maven-archetype
autopep8
nsq
crtdbg.h
fxmlloader
system.net
indic
drawable
serializer
pyalgotrade
visual-studio-setup-proje
farpoint-spread
carrier
boofcv
ekevent
myrrix
infomaker
kohana-orm
wpa
select2-rails
qmainwindow
brew
phone-state-listener
boost.build
orchestration
bindinglist
nsscrollview
erlide
jqzoom
umfpack
file-processing
auto-compile
lwp
activescaffold
chromebug
webdb
web-search
focus-stealing
atmega16
authkit
vista64

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile