Blitz Stealing Window Events
Archives Forums/Win32 Discussion/Blitz Stealing Window Events| 
 | ||
| Has anyone made a library to compensate for (I think) Blitz3d stealing mouse events that are sent to windows? This library would use Win32's window messages to get the various mouse events. When I have a routine check for mousedown(2), for instance, Blitz recieves the message, but no other window connected to it can. (Thus, my GUI gadgets do nothing). I was working on that very library, but I'm now taking a break and I can tell that there's still some work to be done, so I'm hoping that it is already done by someone else. | 
| 
 | ||
| Maybe you can catch them in blitz and fire them off again. ;) | 
| 
 | ||
| Nah, too much thinking. Good idea though. | 
| 
 | ||
| This problem apparently only happens when debug mode is off. Any reasons why this would be? edit: Woops! Double post. | 
| 
 | ||
| I seem to recall putting a Delay in the Blitz3D program will -help- the situation...  it won't solve it, but a delay of 10 (or better yet 100) mostly works well. I used this method for a Blitz3D / BlitzPlus combo program... BlitzPlus seemed unresponsive but it was because it was given nothing to respond to ;] | 
| 
 | ||
| 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. | 
| 
 | ||
| Got it. Are there any key words you can remember from that thread? Edit: I think this could be the thread you're thinking of: http://www.blitzbasic.com/Community/posts.php?topic=30511 (Post by Peter) Anyone want to compile that for me? Edit Edit: I love to brag. This won't work for everyone, but it works for me - and actually is a good feature! I put my renderer and input recieving functions inside of If apiGetFocus()=visWin, so that it won't steal events from a window when it's not in focus (and, obviously, nobody wants something to happen when it's not in focus) I am the KING of weird solutions! |