We saw some time ago that
the GetWindowLongPtr
function returns a magic cookie if it needs to thunk the message.
The CallWindowProc
function
understands this magic cookie and calls the original window procedure
after converting the message to the appropriate character set.
But what if you want to get the actual window procedure and not a thunk?
(For example, because you're writing some debugging or diagnostic code,
and you want to log the actual window procedure address.)
The system returns a thunk if you call
GetWindowLongPtrA
but the window procedure expects Unicode messages,
or if you call
GetWindowLongPtrW
but the window procedure expects ANSI messages.
So you can avoid the character set thunk by checking
the character set of the top-level window procedure
by calling IsWindowUnicode
.
If it reports that the top-level window procedure is Unicode,
then use
GetWindowLongPtrW
.
Otherwise, use
GetWindowLongPtrA
.
Unrelated bonus chatter:
This blog has been running for 15 years now.
Sorry I didn't celebrate with some super-fascinating topic.