【发布时间】:2018-07-24 16:13:11
【问题描述】:
正如here 所述,我设法拥有一个可以点击的 Windows 窗体。
我(我认为这个问题最)相关的代码部分如下:
首次导入:
...
Imports System.Runtime.InteropServices
...
然后定义和导入 DLLs
...
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
...
最终使用它
...
InitialStyle = GetWindowLong(Me.Handle, -20)
PercentVisible = 0.8
SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20)
SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2)
...
如前所述,此代码可以通过 windows 窗体单击,因此单击到达放置在 windows 窗体后面的程序。在我看来,最好将该功能描述为部分或整个显示器的滤色器。
是否有可能以这样的方式修改代码,只在表单中传输左键?需要单击鼠标右键才能打开上下文菜单等...
【问题讨论】:
标签: vb.net