Skip to content

How to create a new window with OwnerWindowId? #3680

Answered by castorix
zhuxb711 asked this question in Q&A
Discussion options

You must be logged in to vote

How to set the Owner of a "Window"?

It can be done with GWL_HWNDPARENT

Quick test with a Window (can be checked with Spy++) :

           Button btn1 = new Button()
            {
                Content = "Click",
                HorizontalAlignment = HorizontalAlignment.Center
            };              
            Window wnd1 = new Window()
            {
                Content = btn1
            };
            IntPtr hWnd1 = WinRT.Interop.WindowNative.GetWindowHandle(wnd1);
            Microsoft.UI.WindowId windowId1 = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd1);
            Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(wind…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@zhuxb711
Comment options

@DarranRowe
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by zhuxb711
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants