The documentation for this function isn't accurate, or is at least very confusing. The documentation seems to imply that each thread's messaging queue can have, independently, its own "active" window, regardless of what is the global active window that is actually receiving user input. This does not seem to be the case.
A system has only one active window, which GetForegroundWindow() returns. GetActiveWindow() seems to return the same window as GetForegroundWindow() if the foreground window belongs to the current thread. Otherwise, it always returns null, rather than the topmost window of the calling thread.