Skip to content

SetActiveWindow can return NULL in case of success - #2169

Open
Nikita Leontiev (nikita-leontiev) wants to merge 1 commit into
MicrosoftDocs:docsfrom
nikita-leontiev:setactivewindow
Open

Nikita Leontiev (nikita-leontiev) wants to merge 1 commit into
MicrosoftDocs:docsfrom
nikita-leontiev:setactivewindow

Conversation

@nikita-leontiev

Copy link
Copy Markdown
Contributor
  1. 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.
  2. Trailing spaces removed.

@prmerger-automator

Copy link
Copy Markdown

Nikita Leontiev (@nikita-leontiev) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — accurate technical correction. Approved.

@GrantMeStrength

Copy link
Copy Markdown
Contributor

Copilot /review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ✅ — Documentation improvement looks good.

@prmerger-automator

Copy link
Copy Markdown

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)

@prmerger-automator

Copy link
Copy Markdown

Nikita Leontiev (@nikita-leontiev) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 NULL return 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants