So I'm looking to understand sub-classing instead of blindly using some sample code segments that really sometimes simply just don't fit "as is" with what I'd be trying to do. Below is a pseudo-code of a custom window procedure that I'm using, but having trouble understanding and subsequently tailoring it to my need:
I can understand the need to check if the system message is destined to myhook or not, and following, the need to redirect the system message to the default window procedure to be handled. However, here's what I don't get:
1. How can a system message that is not destined to myhwnd reach my custom procedure?
2. Regardless, what's the use of the 2nd CallWindowProc call? What's the reasoning behind this chaining logic?
If someone could explain in plain words. because I've read some material about different sub-classing techniques, but I still have unanswered questions.
Thanks in advance.
Code:
Function MyCustomWindowProcedure(hwnd, msg, wparam, lparam)
If hwnd = myhwnd Then
If msg = myhook Then
'Handle wparam and lparam
Else
CallWindowProc(defaultWindowProcedure, hwnd, msg, ....)
End If
Else
CallWindowProc(defaultWindowProcedure, hwnd, msg, ....)
End If
End Function
1. How can a system message that is not destined to myhwnd reach my custom procedure?
2. Regardless, what's the use of the 2nd CallWindowProc call? What's the reasoning behind this chaining logic?
If someone could explain in plain words. because I've read some material about different sub-classing techniques, but I still have unanswered questions.
Thanks in advance.