Stored window positions are out of screen


A user of my plug-in MFis Wire uses two screens in the office. He used to move the dialogs of my plug-in to the second screen. Then he worked at home without external screen, the Plug-In dialogs then were opened somewhere out of the screen. It was not possible to move the dialog windows back into the screen. The only solution was to delete the file window_positions-Scheme__Default.xml in the plug-in folder. The deleted file is attached.window_positions-Scheme__Default.xml (2.3 KB). The example position entry below shows that the x coordinate is 2031, typically out of a screen:

  <child key="MFisWire.Views.LicenseDialog" hidden="True">
    <entry key="RestoreBounds">2031,149,2,2</entry>

I was able to reproduce the issue by copying the above file into my plug-in directory, both under Rhino 6 and Rhino 7. I’m using the proposed code for restoring and saving the dialog positions:

            // show dialog
            var dialog = new WireTemplatesDialog(doc);
            dialog.ShowSemiModal(doc, RhinoEtoApp.MainWindow);

I would like to prevent such issues for users of my Plug-In. This could either by only remebering the dialog positions during a session and not saving it to a file or better by detecting that a dialog position is out of screen and moving it back into the screen automatically. How could I achieve one of the two solutions? However best would be if the extension method RestorePosition() handles this correctly, since the issue could arise with all plug-ins saving and restoring dialog positions.

Looking forward to hearing your suggestions,


@JohnM - can you have a look at this issue?

I tested this using the following code and it works correctly, notice where the location/size is saved and restored. I can save the test dialog with a large portion of it off the screen and see it get forced back on the scree. I can also save the dialog, close Rhino, manually change the XML file changing the save location to large negative numbers I know are invalid and watch the dialog get forced on a screen when I run again. Try my test code in your plug-in and see what happens with the simple test dialog please.

  public class TestSaveDialogPos : Rhino.Commands.Command
    public override string EnglishName => "TestSaveDialogPos";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      var dialog = new TestDlg();
      return dialog.ShowSemiModal(doc, RhinoEtoApp.MainWindow);

    class TestDlg : Dialog<Result>
      public TestDlg()
        Title = "Test Save Dialog Position";
        Resizable = true;
        Size = new Size(400, 400);
        var button = new Button { Text = "Button" };
        button.Click += (s, e) => Close(Result.Success);
        Content = button;
      protected override void OnLoadComplete(EventArgs e)
      protected override void OnClosing(CancelEventArgs e)

Hi John,

Thank you for providing this code. I changed now my plug-in code such that RestorePosition() and SavePosition() are called from within the methods OnLoadComplete and OnClosing as in your example. For most cases, this moves the dialogs back to the screen. However if the stored position is something like 2894,183,2,2 with the third and fourth number equal to 2, the dialog only moves back when opened the second time. I don’t know why there is …,2,2 in the users window_positions-Scheme__Default.xml. May be this only happens when using SavePosition() and RestorePosition() in the way I used it before.

In the Rhino Developer Samples, SavePosition() and RestorePosition() is used as I used it in my plug-in before and it also shows the general issue that the windows are not moved back into the screen. Might be good to update the sample: