Sorry, you are right. That code archive entry is not what I thought it was, and the keyboard hook functions seems to have been deleted from this forum.
This is what I've done (following a tip in these forums) to install a keyboard hook, to use normal windows controls in a Blitz3D window.
In the KeyboardHookProc, I guess you could put your code, to get custom keypresses. You have to add the code to copy to the bank passed.
Powerbasic dll:
Blitz hookdll userlib:
Blitz3D code and User32.decls:
This is what I've done (following a tip in these forums) to install a keyboard hook, to use normal windows controls in a Blitz3D window.
In the KeyboardHookProc, I guess you could put your code, to get custom keypresses. You have to add the code to copy to the bank passed.
Powerbasic dll:
#Compile Dll "C:\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
Blitz hookdll userlib:
.lib "bbhook.dll" hook%(bank*):"hook" unhook%(bank*):"unhook"
Blitz3D code and User32.decls:
;-User32.decls Begin ------------------------------------------------------- ;.lib "User32.dll" ;User32_CreateWindowEx%(dwExStyle,lpClassName$,lpWindowName$,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam):"CreateWindowExA" ;User32_GetWindowLong%(hWnd,nIndex):"GetWindowLongA" ;User32_SetWindowLong%(hWnd,nIndex,dwNewLong):"SetWindowLongA" ;User32_FindWindow%(lpClassName$,lpWindowName$):"FindWindowA" ;-User32.decls End ------------------------------------------------------- Const WS_CHILD = $40000000 Const WS_MINIMIZE = $20000000 Const WS_VISIBLE = $10000000 Const WS_CLIPCHILDREN = $2000000 Const WS_BORDER = $800000 Const WS_TABSTOP = $10000 Const GWL_STYLE = -16 Const WS_EX_CLIENTEDGE = $200 Const WS_EX_LEFT = $00000000 Const ES_LEFT = 0 Const ES_CENTER = 1 Const ES_RIGHT = 2 Graphics3D 800,600,0,2 title$="My title" AppTitle title$ ; find blitz window handle bbHwnd= User32_FindWindow("Blitz Runtime Class",title$) ; get blitz window style style=User32_GetWindowLong(bbHwnd,GWL_STYLE) ; add clip children style, so that controls are not blitted over ret= User32_SetWindowLong(bbHwnd,GWL_STYLE,style Or WS_CLIPCHILDREN) ; Create a button: ret=User32_CreateWindowEx(0,"Button","I am a button",WS_CHILD Or WS_VISIBLE,10,10,100,20,bbHwnd,101,0,0) style=WS_BORDER Or ES_LEFT Or WS_CHILD Or WS_TABSTOP Or WS_VISIBLE exStyle=WS_EX_CLIENTEDGE Or WS_EX_LEFT ; Create a edit box: ret=User32_CreateWindowEx(exStyle,"Edit","The edit box",WS_CHILD Or WS_VISIBLE,10,40,400,20,bbHwnd,101,0,0) cam=CreateCamera() CameraViewport cam ,100,100,400,400 Viewport 100,100,400,400 PositionEntity cam ,0,0,-4 light=CreateLight() RotateEntity light,10,30,0 cube =CreateCube() mybank=CreateBank(40) hook mybank While Not KeyHit(1) TurnEntity cube,1,2,3 UpdateWorld() RenderWorld() Text 100,100,"hello " Flip Wend unhook mybank End