VB.NET

2014-07-25 2 views
-1

양식을 통해 클릭 연결 해제 여기에서 검색 한 코드를 사용하여 : VB.net Click through form, 마침내 "클릭 연결"이 작동하지만 클릭 연결을 해제하는 방법이 여전히 혼란 스럽습니다.VB.NET

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 

내가 안 함이이 코드 내에서 아마 알고,하지만 난 그것을 작동되지 수, 도움의 종류는 크게 감사합니다 :

Public Sub BlaButton_click (blah blah) handles bla bla 
     SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20) 
     SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2) 
End Sub 
+0

일반적으로 마법 번호에 Const 선언문을 사용하는 것이 현명합니다. 그렇게 실수로 -16을 사용하지 않았고 InitialStyle 만 사용하여 스타일을 재설정 한 것으로 보았을 것입니다. –

답변

0

좋아 내가 직접 해결했습니다 , 그냥 매개 변수를 지울 필요가 있습니다.

난 그냥 값이 & H20이 경우에서 "WS_EX.Transparent"값을 제거해야합니다, 그래서 난

및 제거 "& H20 또는"을

SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20) 
SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2) 

전에 코드 다른 것은이 "PercentVisible"승수를 제거하는 것입니다, 나는

후 "* PercentVisible"

코드를 제거

SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000) 
SetLayeredWindowAttributes(Me.Handle, 0, 255, &H2) 

이제 매력처럼 작동합니다.