|
-
Dec 27th, 2001, 11:56 AM
#1
Thread Starter
Frenzied Member
Hook
This is NOT a joke.
Could someone explain to me what a hook is? I REALLY need to know that before I progress further in API.
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Dec 27th, 2001, 12:06 PM
#2
It's another name for subclassing - intercepting messages that are going to another window or control, playing with them, then sending them on to the window/control (or not).
You can also hook input devices - Serge posted a nice piece of code on doing the keyboard with VB.
See:
http://www.vbforums.com/showthread.p...hreadid=129579
-
Dec 27th, 2001, 06:56 PM
#3
Originally posted by jim mcnamara
It's another name for subclassing
I would have to disagree with that. The main purpose of hooks are to monitor special events. Unlike subclassing, hooks do not require you to replace a window procedure, or pass any messages to a window procedure. Instead, they require that you send the message to the next hook in the hook chain so that other hook procedures can receive the message. Also, unlike subclassing, hooks allow you to view a message before it is sent to a window, while it's in the message queue, and after it's been processed. Another thing is that hooks are associated with a thread, whereas subclassing is associated with a window.
-
Dec 27th, 2001, 08:27 PM
#4
Thread Starter
Frenzied Member
So, Megatron, a hook is kind of like the PeekMessage function in C++.
(Oh, and by the way, Megatron is actually a Predacon in Transformers. The Decepticons were formed after Megatron arrived, when the Predacons, using Dr. Koji, found the spaceship. Scourage is the leader of the Decepticons).
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Dec 27th, 2001, 08:58 PM
#5
I disagree - a hook is a subset of subclassing. We're arguing over a definition.
In subclassing you intercept then retain or change some messages (sometimes). With a hook you intercept a message (or several messages). You basically note a message passage thru the system.
In either case, you are getting into a virtual device's (windows are virtual devices) message stream and doing something with the message content.
You DO usually hook real devices, seldom windows. You can hook a window. I just wrote one in C++ last week.
Base definition: hook = intercept message stream
Base definition: subclass = intercept message stream ++
-
Dec 27th, 2001, 09:05 PM
#6
MicroBasic - PeekMessage is api. It works in VB, too. There is also PeekConsoleInput & PeekNamedPipe.
And you intercept & block messages with it. Read about it VS help. It only works on a hWnd-owning device. The keyboard can be hooked, it doesn't have a hWnd.
Not that this clears up a lot. But your analogy is pretty close.
-
Dec 27th, 2001, 09:33 PM
#7
Thread Starter
Frenzied Member
Ah, I am confusing.
What I mean is, hook:devices and windows :: PeekMessage:window
So then, other than the obvious difference that hooks can be used anywhere (excuse the phrasing), what other differences are there between hooks+subclassing?
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Dec 28th, 2001, 12:46 PM
#8
Saying that Hooks and Subclassing can both intercept messages is OK, but saying that Hooks is another name for subclassing can be a bit vague. You cannot catch a window before it is created (no intercepting the WM_CREATE event) but you can use hooks to monitor for a WM_CREATE event, then subclass it. Also, you cannot subclass the keyboard or mouse, but you can install a hook to [i]monitor[/b] messages. One of the big differences is that hooks can capture a message before it is sent to a window's message queue.
Read my first post for some more differences
(Oh, and by the way, Megatron is actually a Predacon in Transformers. The Decepticons were formed after Megatron arrived, when the Predacons, using Dr. Koji, found the spaceship. Scourage is the leader of the Decepticons).
Are you referring the comic book, or the TV series? In the TV series, Scourge was created after Meg died (with Galvatron, Cyclonus, and the other Sweeps).
-
Dec 28th, 2001, 07:53 PM
#9
Thread Starter
Frenzied Member
Thanks.
I'm referring to the TV series. However, Megatron scanned Optimus into Scourge. Then, Scourge worked under Megatron (even though he planned to take over).
Does your Transformers have the Build Team, the Trains, the Race Cars (Dont ask me their names), and The Predacons: Skybyte, Gas Skunk, Slapper, etc.? Because from what I've seen on FOX, Megatron did not die when Scourge was created.
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Dec 28th, 2001, 08:14 PM
#10
Oh! Now I see where the confusion is. I was referring to the G1 episodes back in the day (17 years ago I think). You're talking about the new Car Robots episodes, right?? Since I didn't like Beast Machines (the series before Car Robots) too much, I didn't even bother watching Car Robots.
-
Dec 29th, 2001, 12:39 PM
#11
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|