Document HWNDPARENT (-8) for SetWindowLong... to Clarify Window Ownership - #1982
Merged
Jim Walker (jwmsft) merged 8 commits intoMar 4, 2025
Merged
Jim Walker (jwmsft) merged 8 commits into
Jim Walker (jwmsft) merged 8 commits into
Conversation
|
Zakaria Tahri (@Zakariathr22) : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
Contributor
Author
|
Jim Walker (@jwmsft) |
Jim Walker (jwmsft)
approved these changes
Mar 4, 2025
Contributor
|
Zakaria Tahri (@Zakariathr22), thanks for the updates, and for providing links to sources. |
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
HWNDPARENT (-8)to the documentation forSetWindowLong...functions. This value exists in the Windows API but was not previously documented. The update clarifies its role and ensures developers can use it correctly.Reason for Change
HWNDPARENTis a valid window attribute that allows setting the owner of a top-level window.SetWindowLong...when managing window relationships.Changes Made
HWNDPARENT (-8)to the table of validSetWindowLong...values.Impact
SetWindowLongPtr(GWLP_HWNDPARENT)andSetParent().Sources
YouTube Video - minute: 52:00
Additional Context
In the first mentioned source above, I’m not sure if the "Set Owner Window" approach was presented solely as a hack, but it is an effective solution that proves useful in many scenarios. It is widely used by developers, including in WPF, as seen in the WPF source code. Personally, I use this approach in WinUI 3 by leveraging C#/Win32 P/Invoke, as demonstrated in this use case example.
Please let me know if any further improvements are needed!