简体   繁体   中英

WPF Child Window - Remote Desktop Session

We have a WPF application that has a main window, and 1 child window shown by ShowDialog with ShowInTaskBar set to false.

We save their positions on close, and set Window.Left and Top when re-opened.

Problem is, when you remote desktop into a computer with multiple monitors and then open the child window with a saved position offscreen, there is no way to bring it onto the single monitor.

Is there a something we can change on the child window to make windows handle this issue? The main window doesn't have this issue (I thought it might be related to ShowInTaskBar or the fact it is the main window).

Is there a better way for us to store the window location?

There is no default way within WPF to access any available screen other then the primary screen.

WPF does have SystemParameters.PrimaryScreenHeight and SystemParameters.PrimaryScreenWidth to work with the primary screen however to get information on screens excpluding the primary you would have to make use of the System.Windows.Forms.Screen class.

If you went the System.Windows.Forms.Screen class route you could save relevant data about the window based on the screen at which it resides. Then upon reading the values in you can force the window to the desired screen based on the number of screens residing in the System.Windows.Forms.Screen.AllScreens array. It gives you flexibility for placement as you can take advantage of all available screen within the system versus just the primary.

EDIT:

If you are not concerned with getting the screen information in a modular manner (information per screen versus the aggregate of all available screens) and do not want to make use of the System.Windows.Forms.Screen class you can make use of the SystemParameters.VirtualScreen* properties which will provide the aggregate of available screens.

It should always be possible to get any window back on screen. The following steps hook the currently active window to the mouse cursor:

  • Press Alt+Space to open the system menu
  • Press M for 'Move'
  • Press the right arrow key
  • now move the mouse

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM