![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Sup guys,
Why is it that timers remove your hooks(in my case a mouse hook(WH_MOUSE_LL))? Thanks. |
|
|
|
|
|
#2 |
|
12 years old
Join Date: Nov 2007
Posts: 93
Rep Power: 1
![]() |
Re: Timers and hooks -
They do?
I thought you'd just have to call UnhookWindowsHook(Ex). Oh, and thats a low level mouse hook, not just a mouse hook. |
|
|
|
|
|
#3 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 544
Rep Power: 4
![]() |
Re: Timers and hooks -
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: Timers and hooks -
Quote: Crappy
:suprised: Harsh... ![]() Hmm, according to the replies I think that timers don't remove hooks. Well I guess I'll revise my code and see what went wrong... It may be crappy code... Thanks for now. |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: Timers and hooks -
It took me some time but here is the offending code(the following code is what is causing problems) -
c++ Syntax (Toggle Plain Text)
Do you see any problems? Thanks. Last edited by Ancient Dragon; Jan 26th, 2008 at 5:38 PM. Reason: add line numbers for easier referencing |
|
|
|
|
|
#6 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 544
Rep Power: 4
![]() |
Re: Timers and hooks -
Quote:
![]() line 2: why are you using numbers like that in the switch statement instead of the pre-defined macros from windows.h? It might work for now, but there is no guarentee those values won't change in the future. line 9: why are you deleting the same menu multiple times? The first parameter is supposed to be HWND, don't know what WindowList is, but its value never changes inside that loop. Its possible that is whats producing the problem - line 19: remove the & from in front of WinProc. Functions are always passed by reference so the & symbol is not needed. line 20: what is the value of WndList.size() at that point? Answer: 0 because it was emptied on line 15. Consequently lines 23 and 24 will never get executed. |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: Timers and hooks -
Well actually this is how I get all the open windows into a menu...
Quote: remove the & from in front of WinProc. Functions are always passed by reference so the & symbol is not needed. R. I didn't know that, thanks! Quote: line 20: what is the value of WndList.size() at that point? Answer: 0 because it was emptied on line 15. Consequently lines 23 and 24 will never get executed. Maybe things will clear up if you have a look at this - c++ Syntax (Toggle Plain Text)
That's basically what is happening in EnumWindows(...). Every three seconds(202, this is in WM_TIMER - which is why I am using a number) a menu called WindowList lists all the windows in the taskbar. You should now be able to see why I use WndList.clear() to clear all the windows in the array; to get a fresh list of new ones. Quote: line 9: why are you deleting the same menu multiple times? The first parameter is supposed to be HWND, don't know what WindowList is, but its value never changes inside that loop. Its possible that is whats producing the problem - R. Soory, the first parameter is HMENU ![]() Any ideas? Thanks. |
|
|
|
|
|
#8 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 544
Rep Power: 4
![]() |
Re: Timers and hooks -
Ok I understandand now about that WinList problem.
>>R. Soory, the first parameter is HMENU Right, but the problem still exists. The value of that variable still doesn't change between loop iterations. My suggestion is to remove the loop around that line so that it gets executed only once. Sending an invalid HMENU to that function might produce undesireable and unpredictable results. |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Dec 2007
Posts: 93
Rep Power: 1
![]() |
Re: Timers and hooks -
But WndList is being changed in EnumWindows(), I think I should mension that WndList is a vector<HWND> and in EnumWindows() I am appending handles to windows...
Any ideas? Thanks. |
|
|
|
|
|
#10 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 544
Rep Power: 4
![]() |
Re: Timers and hooks -
are you deaf or something? you still don't get it? We are not talking about WinList but WindowList
for(CurWndNo = WndList.size(); CurWndNo > 0; CurWndNo--)
{
DeleteMenu(WindowList, 0, MF_BYPOSITION);
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|