HKComputer
asked on
How can I disable click through on my transparent form?
I'm using this procure to update my form when the user changes the slider. If they enable click-through by checking the checkbox, then click-through becomes active after changing the slider. The problem is that I can't find a way to disable click-through.
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
If Me.chkClickThrough = False Then
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
Else
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or WS_EX_TRANSPARENT 'Click Through
End If
SetLayeredWindowAttributes Me.hwnd, 0, bTrans, LWA_ALPHA
If the user users Alt+Tab they can set focus on my application / form. Then if they press F10, it will uncheck click-through and run this code that doesn't work:
Case vbKeyF10
Me.chkClickThrough = False
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, bTrans, LWA_ALPHA
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
If Me.chkClickThrough = False Then
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
Else
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or WS_EX_TRANSPARENT 'Click Through
End If
SetLayeredWindowAttributes
If the user users Alt+Tab they can set focus on my application / form. Then if they press F10, it will uncheck click-through and run this code that doesn't work:
Case vbKeyF10
Me.chkClickThrough = False
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes
If you look at your form in the design view and click inside the form, one option is Tab Order, you can remove access to any of the fields you choose.
ASKER
I fixed the problem already. Logic bug:
Case vbKeyF10
Me.chkClickThrough = False
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED '<----Removed lOldStyle
SetLayeredWindowAttributes Me.hwnd, 0, bTrans, LWA_ALPHA
Case vbKeyF10
Me.chkClickThrough = False
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = sliderTrans.Value
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED '<----Removed lOldStyle
SetLayeredWindowAttributes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.