Codice errore sconosciuto

giovedì 14 settembre 2006 - 16.11

henry17ttt Profilo | Junior Member

salve a tutti, il seguente codice non presenta errori nella sintassi, ma talvolta durante l´esecuzione dell´applicazione a runtime, l´applicazione si blocca e deve per forza essere chiusa... posto il codice...


Public Function Keyboard_Proc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim bProc As Boolean = False

Try
If nCode = HC_ACTION Then
Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key

If Form1.chk_alt_tab.Checked Then
bProc = ((lParam.vkCode = VK_TAB) And (CBool(lParam.flags And LLKHF_ALTDOWN) <> 0))
End If

If Form1.chk_alt_esc.Checked Then
If Form1.chk_alt_tab.Checked Then
bProc = bProc Or ((lParam.vkCode = VK_ESCAPE) And (CBool(lParam.flags And LLKHF_ALTDOWN) <> 0))
Else
bProc = ((lParam.vkCode = VK_ESCAPE) And (CBool(lParam.flags And LLKHF_ALTDOWN) <> 0))
End If
End If

If Form1.chk_ctrl_esc.Checked Then
If Form1.chk_alt_tab.Checked Or Form1.chk_alt_esc.Checked Then
bProc = bProc Or ((lParam.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL)) <> 0))
Else
bProc = ((lParam.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL)) <> 0))
End If
End If
End Select
End If

If bProc = True Then
Return 1
Else
Return CallNextHookEx(0, nCode, wParam, lParam)
End If

Catch ex As Exception

End Try

End Function

***nota: le costanti sono giá state definite


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
UnhookWindowsHookEx(iHook)
End Sub




Private Sub btn_key_combinations_control_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_key_combinations_control.Click

iHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf Keyboard_Proc, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32(), 0)

End Sub




grazie.






enri

19018 Profilo | Expert

Così è difficile aiutarti.Provalo in degub mode e cerca di capire l'errore specifico oppure nei vari catch esegui una scrittura su un file dell'errore.ciao

Stefano Passatordi

http://blogs.dotnethell.it/stem/

henry17ttt Profilo | Junior Member

ok problema risolto.

------------------
enri
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5