How can I find the position of a maximized window?

前端 未结 7 1578
走了就别回头了
走了就别回头了 2020-12-30 05:23

I need to know the position of a window that is maximized.

WPF Window has Top and Left properties that specifies the window\'s location. However, if you maximize the

7条回答
  •  感情败类
    2020-12-30 05:40

    I realize that you are working in WPF, and this answer makes use of Forms technology, but it should work without much difficulty.

    You can get a collection of the screens through My.Settings.Screens.AllScreens. From there you can access the resolution that the screen is currently working on.

    Since WPF windows retain the Top/Left values that they had when they were maximized, then you can determine which screen they are on by figuring out which screen that Top/Left coordinates refer to, and then get the top/left coordinate for that screen.

    Unfortunately, I am on the road, and can't test this at the moment. If you do implement, I would love to see what you come up with.

提交回复
热议问题