This one sends commands form one window to another. I use it in Blitz+ to subclass an Htmlview in order to get the keystrokes. It shows one principle of getting events, before Blitz gets them.
// blitzpipe.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "Windows.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall
WNDPROC gSourceProc;
WNDPROC gDestProc;
HWND gSrcWindow;
HWND gDestWindow;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_KEYDOWN:
//MessageBox(0,"WM_KEYDOWN","her",MB_OK);
SendMessage( gDestWindow, uMsg, wParam, lParam);
return CallWindowProc(gSourceProc, hwnd, uMsg, wParam, lParam);
case WM_KEYUP:
//MessageBox(0,"WM_KEYUP","her",MB_OK);
//return CallWindowProc(gDestProc, hwnd, uMsg, wParam, lParam);
SendMessage( gDestWindow, uMsg, wParam, lParam);
return CallWindowProc(gSourceProc, hwnd, uMsg, wParam, lParam);
default:
return CallWindowProc(gSourceProc, hwnd, uMsg, wParam, lParam);
}
return 0;
}
BBDECL int BBCALL InstallPipe(HWND src, HWND dest)
{
gSrcWindow = src;
gDestWindow = dest;
//MessageBox(0,"InstallPipe","her",MB_OK);
gSourceProc = (WNDPROC)SetWindowLong(gSrcWindow, GWL_WNDPROC, (LONG)WindowProc);
gDestProc = (WNDPROC)GetWindowLong(gDestWindow, GWL_WNDPROC);
return true;
}
BBDECL int BBCALL UnInstallPipe()
{
if (gSourceProc != 0){
SetWindowLong(gSrcWindow, GWL_WNDPROC, (LONG)gSourceProc);
gSourceProc = 0 ;
}
return true;
}
This one is only good for one window and one instance of the dll, because of the globals. A better way can be to store your variables in the userdata section of the windows with GetWindowLong() and SetWindowlong()
There also used to be a nice example somewhere in these forums, of how to make windows controls work in Blitz3D by using a keyboard hook, alowing for native windows textboxes and menus.