Click here to Skip to main content
15,885,842 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I'm looking for a source sample to detect any window move (thus, a global hook) in x86/x64 windows systems.
I've searched a bit but all I found about global hooks end in keyboard/mouse samples.

I've checked the MinHook project which comes with different type of keyboard samples but when I tried to adapt it to detect any WM_MOVING (MoveWindow) event, I wasn't able to make it work.

UPDATE: I finally managed to hook the window move event (hooking the Windows'API DefWindowProcW
with event number WM_MOVING = 0x0216).
The problem is that MinHook only works locally on the own app's events and not globally as I was intending.

The reason I was looking for a sample is because I am not a C++ expert and was looking for some sort of sample to ahve a look.

Thank you in advance.
Posted
Updated 20-May-14 1:00am
v2
Comments
Rage 20-May-14 6:41am    
Why are you not implementing a hooking function of your own using the API ?
What do you mean with "was not able to make it work?"
Member 10562606 20-May-14 7:01am    
I finally managed to hook the window move event (hooking the Windows'API DefWindowProcW
with event number WM_MOVING = 0x0216).
The problem is that MinHook only works locally on the own app's events and not globally as I was intending.

The reason I was looking for a sample is because I am not a C++ expert and was looking for some sort of sample to ahve a look.

Thank you.
Rage 20-May-14 7:02am    
OK, well done !

1 solution

This article has some useful information on creating a DLL that loads into each applications's address space. The article is a bit dated in that the advice on creating a shared section of memory doesn't work with Windows Vista and later.

Hooks and DLLs[^]

The key is - I think - the WH_GETMESSAGE hook mechanism. It will give all windows messages returned by GetMessage.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms644959%28v=vs.85%29.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900