SetActiveWindow can return NULL in case of success - #2169
Nikita Leontiev (nikita-leontiev) wants to merge 1 commit into
Conversation
Nikita Leontiev (nikita-leontiev)
commented
Jan 29, 2026
- SetActiveWindow can return NULL in case of success. Before calling SetActiveWindow, GetActiveWindow returned NULL. After calling SetActiveWindow, GetActiveWindow returned handle that was passed to SetActiveWindow, i.e. success, but SetActiveWindow returned NULL. In this case SetActiveWindow was called from WH_MOUSE hook proc.
- Trailing spaces removed.
|
Nikita Leontiev (@nikita-leontiev) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
John Kennedy (GrantMeStrength)
left a comment
There was a problem hiding this comment.
LGTM — accurate technical correction. Approved.
|
Copilot /review |
John Kennedy (GrantMeStrength)
left a comment
There was a problem hiding this comment.
Reviewed ✅ — Documentation improvement looks good.
|
Nikita Leontiev (@nikita-leontiev) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. Jim Walker (@jwmsft) |
|
Nikita Leontiev (@nikita-leontiev) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
There was a problem hiding this comment.
🟡 Changes recommended
Failure guidance must clear last error before calling SetActiveWindow to avoid reporting stale errors.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Clarifies that SetActiveWindow may return NULL on success and removes trailing whitespace.
Changes:
- Documents the ambiguous
NULLreturn value. - Revises failure-detection guidance.
- Cleans up trailing spaces.
File summaries
| File | Description |
|---|---|
sdk-api-src/content/winuser/nf-winuser-setactivewindow.md |
Updates return-value documentation and formatting. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| If the function succeeds, the return value is the handle to the window that was previously active or <b>NULL</b>. | ||
|
|
||
| If the function fails, the return value is <b>NULL</b>. To get extended error information, call <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. | ||
| Function failure is indicated by a return value of <b>NULL</b> and a <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> result that is nonzero. |