I'm posting both my problem and solution here in the hopes that it saves a programmer some time and frustration. Feel free to comment and critique.
The problem had to do with the ShowModelessDialog mechanism remembering my dialog size and location.
Normally this would be a good thing and I would welcome it . . . however I have some users with dual monitors.
They would move my dialog to a second screen, then sometime later would go from two monitors to one. (this can also happen if a user changes resolution)
My dialog would show up off screen. (Bad programmer, you should check for such things)
So I wrote a function (stack-overflow copy paste) to check to see if the form is on a screen and if not set it's location to someplace that is visible.
That should work except the ShowModelessDialog mechanism forces to form to the location *it* remembers and ignores mine.
The solution was to use what was already in the API.
Application.ShowModelessDialog(null, new frmMyForm(), false);
The last argument is persistSizeAndPosition (should be persistSizeAndLocation) and setting it to false gave me back control of my form's location.
By the way, I had to set the first argument to null to get it to work.
I tried (as suggested elsewhere) Application.ShowModelessDialog(Application.MainWindow, new frmMyForm(), false);
But the compiler complained about Application.MainWindow not being a System.IntPtr blah blah blah.
The help said this: "This method calls the ShowModelessDialog(System.Windows.Forms.IWin32Window owner, System.Windows.Forms.Form formToShow) method with owner set to null."
So I set it to null and it stopped complaining.
I'm working with AutoCAD 2010 - VS 2008
CAD Programming Solutions