Holy cow, I wrote a book!
There are many cases where a callback function is allowed to
halt an operation.
For example, you might decide to return FALSE
the WM_NCCREATE message
to prevent the window from being created,
or you might decide to return FALSE
to one of the many enumeration callback functions such as
the EnumWindowsProc callback.
When you do this,
the enclosing operation will return failure back to its caller:
the CreateWindow function
the EnumWindows function
Of course, when this happens, the enclosing operation doesn't
know why the callback failed; all it knows is that it failed.
Consequently, it can't set a meaningful value to be retrieved by
the GetLastError function.
If you want something meaningful to be returned by
the GetLastError function when your callback
halts the operation,
it's the callback's responsibility to set that value
the SetLastError function.
This is something that is so obvious I didn't think it needed to
it falls into the
"because computers aren't psychic (yet)" category of explanation.
But apparently it wasn't obvious enough,
so now I'm saying it.