vb.net在windows窗体中单击,只需单击鼠标右键或左键

vb.net在windows窗体中单击,只需单击鼠标右键或左键,vb.net,Vb.net,如上所述,我成功地创建了一个可以点击的Windows窗体 我的(在我看来,这个问题的大部分)相关代码部分如下: 首次进口: ... Imports System.Runtime.InteropServices ... 然后是DLL的定义和导入 ... Private InitialStyle As Integer Dim PercentVisible As Decimal ... <DllImport("user32.dll", EntryPoint:="GetWindowLong")&

如上所述,我成功地创建了一个可以点击的Windows窗体

我的(在我看来,这个问题的大部分)相关代码部分如下:

首次进口:

...
Imports System.Runtime.InteropServices
...
然后是DLL的定义和导入

...
Private InitialStyle As Integer
Dim PercentVisible As Decimal
...
<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
...
如前所述,此代码使单击windows窗体成为可能,因此单击可以到达放置在windows窗体后面的程序。在我看来,该功能最好描述为部分或整个显示器的滤色器


是否有可能以这样的方式修改代码,即只通过表单传递左键单击?需要单击鼠标右键打开上下文菜单等…

如果要接收鼠标事件,必须从窗口样式中删除
&H20
,如下所示

SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000)

但这会阻止所有鼠标事件在表单中传播。现在,您可以根据需要处理事件。您必须自己将鼠标左键单击相关事件传播到其他应用程序。

如何将鼠标左键单击相关事件传播到其他应用程序?如果您想弄乱这些windows消息,您必须处理它们。从这里开始查找适当的窗口句柄,然后使用SendMessage传播所有相关事件。
SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000)