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
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");
	
	...
}

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


Current Time: Sun Jun 08 01:15:41 CEST 2025

Total time taken to generate the page: 0.04384 seconds