-
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
-
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).
-
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...
-
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.
-
So, what do you do then, call the WNDPROC var? And that'll call the correct WndProc function? Thanks...
-
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.