Callbacks seem to be a really big problem to me. A couple of years ago everything went fine when I subclassed a control or something. But now I try to Debug my own thread and again my VB quits without errormessage:
MODULE
VB Code:
Public Const WH_DEBUG = 9 Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long Public hHook As Long Public Function DebugProc(ncode As Integer, wParam As Long, lParam As Long) As Long CallNextHookEx hHook, ncode, wParam, lParam End Function
FORM
VB Code:
Private Sub Form_Load() hHook = SetWindowsHookEx(WH_DEBUG, AddressOf DebugProc, 0&, GetCurrentThreadId()) End Sub Private Sub Form_Unload(Cancel As Integer) hHook = UnhookWindowsHookEx(hHook) End Sub
I hate it when it does quitting without errormessage. I think my code above is right but maybe one of you might see some errors




Reply With Quote