簡體   English   中英

顯示擁有的窗口而不顯示在前面

[英]Show an owned window without bringing to front

從主窗口顯示沒有所有者的窗口。 然后,主窗口顯示其擁有的窗口。 擁有的窗口將自身和主窗口置於最前面。

我希望擁有的窗口和主窗口在沒有所有者的情況下保持在窗口后面。 在擁有的窗口上將屬性ShowActivated設置為false不會阻止窗口將自己移到最前面,但是可以防止竊取焦點。

關於在調用Show時如何使擁有的窗口保持在無主窗口后面的任何想法?

Window ownerlessWindow = new OwnerlessWindow();
ownerlessWindow.Show();

Thread.Sleep(1000);

Window child = new ChildWindow();
child.ShowActivated = false;
child.Owner = this;
child.Show();

// Bring the ownerless window to the front
ownerlessWindow.Topmost = true;
ownerlessWindow.Topmost = false;
ownerlessWindow.Focus();

在測試應用程序中,上面的代碼確實將無主窗口放回了前面,而窗口順序沒有明顯變化。 在生產應用程序中,窗口順序有一個快速可見的變化。

Window ownerlessWindow = new OwnerlessWindow();

// set the ownerless window topmost first
ownerlessWindow.Topmost = true;
ownerlessWindow.Show();

Thread.Sleep(1000);

Window child = new ChildWindow();
child.ShowActivated = false;
child.Owner = this;
child.Show();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM