Small WinBlitz3D Test

Blitz3D Forums/Blitz3D Programming/Small WinBlitz3D Test

below is PoweBasic code, for a dll, That I *think* made Blitz proces the keystrokes, so that they came throug, and it was possible to catch them in a subclass procedure.

#Compile Dll "d:\blitz3d\userlibs\bbhook.dll"


#Include "WIN32API.INC"

Global gKBHook As Long


Function LibMain(ByVal hInstance As Long, _
                 ByVal Reason    As Long, _
                 ByVal Reserved  As Long) _
                 Export As Long

  Select Case Reason
    Case %DLL_PROCESS_ATTACH
      LibMain = 1
      Exit Function
    Case %DLL_PROCESS_DETACH
      Exit Function
    Case %DLL_THREAD_ATTACH
      Exit Function
    Case %DLL_THREAD_DETACH
'
      Exit Function
  End Select

  LibMain = 0   'failure!
End Function

Function KeyboardHookProc(ByVal code As Long,ByVal wParam As Dword ,lParam As tagmsg) As  Dword
    'Static Msg As tagMsg

    If code<0 Then
           Function= CallNextHookEx(gKBHook,code,wParam,lParam)
           Exit Function
    Else


       '    Call getMessage( lParam, %NULL, 0, 0 ) '= %FALSE 'Then
        If lParam.message=%WM_KEYDOWN Then

        TranslateMessage lParam
        DispatchMessage lParam

        End If


    End If

End Function

Function hook  Alias "hook" (bank1 As Dword) Export As Long
     MsgBox "hooked " & Str$(gKBHook)
    gKBHook=SetWindowsHookEx(%WH_GETMESSAGE,CodePtr(KeyboardHookProc),0,GetCurrentThreadID())

End Function

Function unhook  Alias "unhook" (bank1 As Dword) Export As Long
    UnhookWindowsHookEx gKBHook
    MsgBox "unhooked"
End Function