Click through form?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts
Page 1 of 1
Is there a way to make it so my form is completely transparent to mouse clicks (so the item behind my form gets clicked, and not my form?)
Thanks!
Thanks!
I think you can perform click behind the form using api just by using MouseEvents.Location ?
Im unsure about the usage about the SetCapture and ReleaseCapture API functions, but they might do what you want.
Code: Select all
Private Declare Function SetCapture Lib "User32.dll" (ByVal hWnd As IntPtr) As IntPtr
Private Declare Function ReleaseCapture Lib "User32.dll" () As Boolean
Start capturing:
SetCapture(ItemBehindForm.Handle)
Stop capturing:
Dim success As Boolean = ReleaseCapture()
If Not success Then
MessageBox.Show("Failed releasing capture")
End If
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
MrAksel wrote:Im unsure about the usage about the SetCapture and ReleaseCapture API functions, but they might do what you want.This seems like it is what I am looking for. The only problem I have is the "ItemBehindForm.Handle" part. That code doesn't work :/Code: Select allPrivate Declare Function SetCapture Lib "User32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Function ReleaseCapture Lib "User32.dll" () As Boolean Start capturing: SetCapture(ItemBehindForm.Handle) Stop capturing: Dim success As Boolean = ReleaseCapture() If Not success Then MessageBox.Show("Failed releasing capture") End If
umm im not sure if this works anymore and i cant test it because im getting my computer with vb on it fixed, but you can try changing the forms properties:
1. BAckground Color: Yellow (or any solid color)
2. Foreground Color: (or font color i dont remember): Yellow (same as bg color)
3. Transparency Color: Yellow( same as fg color)
1. BAckground Color: Yellow (or any solid color)
2. Foreground Color: (or font color i dont remember): Yellow (same as bg color)
3. Transparency Color: Yellow( same as fg color)
Cheatmasterbw wrote:it should be the handle of the windowMrAksel wrote:Im unsure about the usage about the SetCapture and ReleaseCapture API functions, but they might do what you want.This seems like it is what I am looking for. The only problem I have is the "ItemBehindForm.Handle" part. That code doesn't work :/Code: Select allPrivate Declare Function SetCapture Lib "User32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Function ReleaseCapture Lib "User32.dll" () As Boolean Start capturing: SetCapture(ItemBehindForm.Handle) Stop capturing: Dim success As Boolean = ReleaseCapture() If Not success Then MessageBox.Show("Failed releasing capture") End If
Axel wrote:That didn't work. I think i need to put the handle of the object behind the form and under the mouse cursor.Cheatmasterbw wrote:it should be the handle of the windowMrAksel wrote:Im unsure about the usage about the SetCapture and ReleaseCapture API functions, but they might do what you want.This seems like it is what I am looking for. The only problem I have is the "ItemBehindForm.Handle" part. That code doesn't work :/Code: Select allPrivate Declare Function SetCapture Lib "User32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Function ReleaseCapture Lib "User32.dll" () As Boolean Start capturing: SetCapture(ItemBehindForm.Handle) Stop capturing: Dim success As Boolean = ReleaseCapture() If Not success Then MessageBox.Show("Failed releasing capture") End If
well afaik, hwnd means the handle of a window (HandleWiNDow, get it ?)
oh and every control is a window too lol
oh and every control is a window too lol
Cheatmasterbw wrote:Look below for the working code, ignore the restMrAksel wrote:Im unsure about the usage about the SetCapture and ReleaseCapture API functions, but they might do what you want.This seems like it is what I am looking for. The only problem I have is the "ItemBehindForm.Handle" part. That code doesn't work :/Code: Select allPrivate Declare Function SetCapture Lib "User32.dll" (ByVal hWnd As IntPtr) As IntPtr Private Declare Function ReleaseCapture Lib "User32.dll" () As Boolean Start capturing: SetCapture(ItemBehindForm.Handle) Stop capturing: Dim success As Boolean = ReleaseCapture() If Not success Then MessageBox.Show("Failed releasing capture") End If
ItemBehindForm is to be replaced with the name of the control that is behind your form. If it is in another process so you cant access it, you better use this code:
Code: Select all
That would probably NOT (edit, look below for working code) work, but I have another way that might work better, ignore everything said in previous posts and just paste what is below anywhere in your form (that is to be click-through).Private Declare Function WindowFromPoint(ByVal point As POINT) As IntPtr
<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>
Private Structure POINT
Public X As Integer
Public Y As Integer
End Structure
'Start capturing'
Dim pos As New POINT
Dim hWnd As IntPtr
pos.X = MouseLocation.X
pos.Y = MouseLocation.Y
hWnd = WindowFromPoint(pos)
If hWnd = IntPtr.Zero Then
MessageBox.Show("Failed getting handle")
Return
End If
SetCapture(hWnd)
Code: Select all
Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams
Get
Dim params As CreateParams = MyBase.CreateParams
params.ExStyle = WS_EX_TRANSPARENT Or params.ExStyle
Return params
End Get
End Property
Private Const WS_EX_TRANSPARENT As Integer = 32
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
That code didn't work :/
EDIT: It works when the form's opacity is not 100%
Thanks
EDIT: It works when the form's opacity is not 100%
Thanks
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023