Thread: WNDPROC type

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    WNDPROC type

    I was looking at some Petzold code for window subclassing, and he has three globals with type WNDPROC. The line is something like this:
    Code:
    WNDPROC OldProc[3];
    I know this creates an array, but why do you have to do this type when defined later in the program? Thanks...

    --Garfield
    1978 Silver Anniversary Corvette

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    I'm not sure I understand your question, but it looks like he's storing the addresses of three WndProc functions for later use (probably to pass messages that he's not overriding an event handler for onto the default WndProc for that type of control).

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I think you are right (I'm not sure because I don't totally understand it). For the window subclassing, it was supposed to handle the 'tab' key to focus on the next scroll bar. Any other ideas? Thanks...
    1978 Silver Anniversary Corvette

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Not using classes so he wants to be able to pass the address of a function into another function like a variable / param.

    Say you had msg incomming (data entered in an edit), the type of data entered determins what function / callback you want to send it to. Floats to one, ints to another ect. He can send in the address of the winproc / function he wants to handle the data. This helps reduce code and add to the flexibility of a function.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    So, what do you do then, call the WNDPROC var? And that'll call the correct WndProc function? Thanks...
    1978 Silver Anniversary Corvette

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You send in a pointer to a function like a pointer to a variable.

    Instead of modifing the contents of the variable, you call a function by address.

    In Petzoid he probably wants to use one function to do all his scrolling, for all his ctrls on all his dialogs.

    He can send the scroll msg's to this function with a pointer to the correct callback to continue on to.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. typename madness
    By zxcv in forum C++ Programming
    Replies: 4
    Last Post: 05-13-2006, 10:35 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM