Results 1 to 11 of 11

Thread: Hook

  1. #1

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402

    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 .

  2. #2
    jim mcnamara
    Guest
    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

  3. #3
    Megatron
    Guest
    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.

  4. #4

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    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 .

  5. #5
    jim mcnamara
    Guest
    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 ++

  6. #6
    jim mcnamara
    Guest
    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.

  7. #7

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    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 .

  8. #8
    Megatron
    Guest
    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).

  9. #9

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    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 .

  10. #10
    Megatron
    Guest
    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.

  11. #11

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Intelligence simplifies the complex.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width