Hook Functions

kugela
09-19-2000, 12:02 PM
I have been investigating how to use and manipulate icons in the system tray, using, of course, the Shell_NotifyIcon API call. I have come across two examples on the Web that differ mostly in how they capture the callback messages.

The first uses the MouseMove event of the controlling window to capture and process the message. This is kinda weird because it seems that the message is received in the X parameter of the MouseMove function and then needs to be divided by the number of twips per pixel given by the Screen object.

My first question is: Why the heck does this work? OR What the heck is going on here?

In the second example, a function to process messages is defined in a *.bas module and then is used to replace the hook function of the controlling window thru the SetWindowLong API call. This new function checks to see if there is a right-click message. If the message is something else, it calls the old hook function using the CallWindowProc API call and the old function's handle that was saved in a global variable.

Second question: What exactly is a hook function? Could someone please clarify and/or give me more info regarding messaging, etc.

Thanks SO much!

Boycott the "HackSDMI Challenge"!!!
www.eff.org

Phil
09-20-2000, 05:12 AM
Hi,

I've got no experience of the first situation so cann't help you there, for info on hooks check out:
http://support.microsoft.com/support/kb/articles/Q170/5/70.ASP?LN=EN-US&SD=msdn&FR=0
And also my favourite API site:
http://www.vbapi.com/
Which has some good stuff about windows messaging, look at the "CallWindowProc" function.
If you're still stuck I can post you some code.

Good Luck
Phil

kugela
09-20-2000, 06:31 AM
Thanks for the links. Actually, www.vbapi.com is where I got the second example. I've been reading that site voraciously, but sometimes it doesn't give the best explanations.

Boycott the "HackSDMI Challenge"!!!
www.eff.org

Derek Stone
09-24-2000, 09:13 AM
Just in case you still want to know.
A hook is basically the trapping of events fired by a window.
Visual Basic lets you trap some of the events, like Form_Resize, but others you must trap yourself.
This is all under the topic of subclassing so when you here any of the above terms think event trapping.
Good Luck
-cl

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum