caznet's avatar
Experienced Partner
8 years ago

Display: Detect missing screen

If you use MYOB on a laptop, and at work have multiple screens but at home just have the laptop screen, MYOB will re-open on the screen that is no longer attached to your computer.


You then need to click click, move, use you keyboard to move the window back into view.


This is an easy fix:


public void loadLastState() {

// variables
bool bLocationVisible = false;

// behave differently if the window was full screen or not last time
if (Properties.Settings.Default.windowIsFullScreen) {

// the window was full screen when it was last closed, just do that
this.WindowState = FormWindowState.Maximized;

} else {

// get the last location
System.Drawing.Point ptLocation = Properties.Settings.Default.windowLocation;

// if it hasn't been set, both X and Y values will be 0, exit
if (ptLocation.X == 0 && ptLocation.Y == 0) { return; }

// Check the point is still on one of our screens
foreach (Screen s in Screen.AllScreens) {
if (s.Bounds.Contains(ptLocation)) { bLocationVisible = true; }

// If the point is one on of our screens, proceed with setting location and size
if (bLocationVisible) {
this.StartPosition = FormStartPosition.Manual;
this.Location = ptLocation;
this.Size = Properties.Settings.Default.windowSize;



1 Comment

  • Status changed:

    Thank you for the idea. Unfortunately, this request has had no support from the community since it was submitted, so we are moving this idea to the Archived status. For more information on Idea Statuses, please read this article: Changes to our Idea Exchange pages