Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Mouse wheel and TopWindow
Mouse wheel and TopWindow [message #5746] Thu, 12 October 2006 18:04 Go to next message
atmks is currently offline  atmks
Messages: 33
Registered: July 2006
Member
hi all

how can i catch mousewheel event
outside topwindow (platform WinXp)?

pressing of mousebutton is simply with GetAsyncKeyState function,
but mousewheel...

bye
atmks

Re: Mouse wheel and TopWindow [message #5754 is a reply to message #5746] Fri, 13 October 2006 05:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
atmks wrote on Thu, 12 October 2006 12:04

hi all

how can i catch mousewheel event
outside topwindow (platform WinXp)?

pressing of mousebutton is simply with GetAsyncKeyState function,
but mousewheel...

bye
atmks





Actually, I did not even knew you can detect mouse button (and you might not be able to do so in Linux). Looks like it is very platform specific, if you really need to have this, digg Windows documentation and maybe some Win related forums (and inform us about the result Wink

Mirek
Re: Mouse wheel and TopWindow [message #6712 is a reply to message #5754] Fri, 24 November 2006 01:34 Go to previous message
atmks is currently offline  atmks
Messages: 33
Registered: July 2006
Member
hi, i finded the solution
i used a dll hook technology:

dll source:
hook.h
#ifndef _hook_hook_h
#define _hook_hook_h

#define DllImport extern "C" __declspec(dllimport)
#define DllExport extern "C" __declspec(dllexport)

#ifdef flagDLL
	#define DLLIMPORT __declspec(dllexport)
#else
	#define DLLIMPORT __declspec(dllimport)
#endif

void DLLIMPORT SetHooks(HHOOK hk,HWND hwnd);
LRESULT DLLIMPORT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);


#endif

hook.cpp

#include <windows.h>
#include <stdio.h>
#include "hook.h"

HHOOK hMouseHook = NULL;
HWND mHwnd = 0;
HWND cur_hwnd = 0;

BOOL APIENTRY DllMain(HANDLE hModule, DWORD reason,  LPVOID lpReserved) {
	switch (reason) {
		case DLL_PROCESS_ATTACH:
			break;
		case DLL_PROCESS_DETACH:
			break;
		case DLL_THREAD_ATTACH:
			break; 
		case DLL_THREAD_DETACH:
			break;
	}
	return TRUE;
}


void DLLIMPORT SetHooks(HHOOK hk,HWND hwnd) {
	hMouseHook = hk;
	mHwnd = hwnd;	
}

LRESULT DLLIMPORT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
	HWND hwnd_spion = FindWindow("spion",0);
	PostMessage(hwnd_spion,nCode,wParam,lParam);
	return CallNextHookEx(hMouseHook,nCode,wParam,lParam);
}


application source
main.cpp:
int WM_MYMOUSEWHEEL;
HMODULE hMod;
HHOOK hHk;
...
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
	if(message==WM_MYMOUSEWHEEL) {
		//mousewheel event
	}
...		
}

GUI_APP_MAIN() {

	WNDCLASS wndclass ;
	...
	wndclass.lpszClassName = TEXT("spion") ;
	...

	hMod = LoadLibrary("hook.dll");
	
	if(hMod == NULL)
		LOG("LoadLibrary failed");
	
	hHk = SetWindowsHookEx(14,&MouseProc,hMod,0);
	if(hHk == NULL)
		LOG("SetWindowsHookEx failed");
	
	SetHooks(hHk,hwnd);
	
	WM_MYMOUSEWHEEL = RegisterWindowMessage("mouse_wheel_rulez");
	
	...
}

Previous Topic: AlignDisplay bug (?)
Next Topic: Tips in .lay files?
Goto Forum:
  


Current Time: Sun May 05 09:20:16 CEST 2024

Total time taken to generate the page: 0.02300 seconds