使用切换可以使用透明/可点击的VB.net表单进行点击

时间:2017-05-16 06:39:52

标签: c# vb.net

所以我正在开发一个透明的附加组件VB.net program,只有在click shift时才可以点击。例如。除非我按住shift f.e

,否则它会留在那里但点击将会通过它

我看到了这个并测试了代码, VB.net Click through form

但是我试图更改一些控件,但没有一个能够给我一种“切换”。我能解决什么问题的任何线索?

C#中的答案是受欢迎的,如果在VB中无法执行,我可以编程C#

编辑:我一直试图使用的代码就是这个

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

编辑2:我需要它才能使控件也可以点击..

示例:

可以设计一个用户将在他的屏幕上看到的倒计时时钟,但是如果他点击它什么也不会发生任何地方,点击将会通过,如果用户想要与该程序进行交互,他将保持Shift和该程序现在可以点击

0 个答案:

没有答案