Ayende @ Rahien

It's a girl

It ain’t no simple feature, mister

I recently got a bug report about NH Prof in a multi monitor environment. Now, I know that NH Prof works well in multi monitor environment, because I frequently run in such an environment myself.

The problem turned out to be not multi monitors in and of itself, but rather how NH Prof handles the removal of a monitor. It turns out that NH Prof has a nice little feature that actually remembers the last position the window was at, and returns to it on start. When the monitor NH Prof was located on was removed, on start NH Prof would put itself beyond the screen position.

That led to me having to figure out how to find the available monitor space, so I could detect if the saved positions were valid or not. What I found interesting in this is that what seemed to be a very trivial feature (save two numbers) turned out to be somewhat more complex, and I am pretty sure that there are other scenarios that I am missing (in the very same feature).

Comments

Filip Navara
09/14/2010 10:21 AM by
Filip Navara

Ah, reinventing the Win32 wheel - Get/SetWindowPlacement - is it not available in some form in WPF?

Dave
09/14/2010 10:33 AM by
Dave

You should also check the weight and width of your windows and check if they still fit. If the desktop is accessed using RDP the desktop dimensions could also change.

In our office dual 22" screens are used, but some employees use 17" laptops to work on the road. Nobody said development was easy..

John Chapman
09/14/2010 12:31 PM by
John Chapman

I doubt you'll run into this with your users, but Windows will also allow non-rectangular desktops. I have seen users that have 4 monitors mounted as a rectangle with 2 on the bottom and 2 on top and then 2 more monitors one on each side.

Perhaps it's flexibility like that which makes it more complicated than 2 numbers?

Also when 2 monitors do not share the same resolution you also have the flexibility of placement for the monitors. Is the smaller monitor in the middle, bottom, top?

These configurations make it seem less than trivial.

Wyatt Barnett
09/14/2010 12:38 PM by
Wyatt Barnett

If it makes you feel any better, lots of programs by big publishers also fail when you take away monitors.

Alex Simkin
09/14/2010 01:38 PM by
Alex Simkin

@John Chapman and Wyatt Barnett

With setup like this users so used to everything not working correctly that NHProf won't make their lives any different.

Stendahl
09/14/2010 02:22 PM by
Stendahl

This is a problem with many windows apps. There must be some tool out there that can bring lost windows onto the screen. For your app I'd suggest a "Forget window positiions" menu action.

Rik Hemsley
09/14/2010 02:23 PM by
Rik Hemsley

TBH this is exactly the sort of thing that developers are supposed to think about and cater for before it happens. Windows is perfectly capable of ensuring that your app is visible when it starts, and you know that the desktop could be spread over multiple screens - and that the configuration may change.

To blithely override the default positioning while ignoring the obvious issues involved - well, I can only say I would be disappointed if any of our developers did the same.

DVins
09/14/2010 09:56 PM by
DVins

This issue drives me crazy with other applications when I undock my laptop...

NC
09/14/2010 11:58 PM by
NC

Never have an issue with losing windows.

With Ultramon, using Windows 7. On the main taskbar, you hover over the taskbar item to bring up the preview, right click the preview and click "Move to other monitor".

Problem solved.

Dave H
09/15/2010 01:57 AM by
Dave H

Just my opinion here but I would put a bug like this pretty low on my priority list. As other people have said, lots of other apps have this issue so even if your app works fine, other apps will break anyway so the end user will have some tidying up to do.

You can also work around the problem to some extent as long as the app's still visible in the task bar: right click the task, select move, press a cursor key and wave your mouse around and the window will come back into the visible area.

Phil
09/15/2010 06:04 PM by
Phil

The good thing is that since it is open source, you will not have to lose sleep fixing it. Plus, probably someone else may fix it for you.

Pure Krome
09/16/2010 02:35 AM by
Pure Krome

For me .. i find that when i Remote Desktop from home to my work PC .. this happens a fair bit :( this is why i make sure i change all my settings/move windows to the primary monitory if i know i'm going to RD to my work machine.

For VS2010 (and i did this for VS2008) i have two window settings -> one for single monitory and another for dual 22" monitors. This is because i'm switching so often between the two.

Thank gawd VS2010 now displays the window positions exactly right when i import the display windows .. in vs2008 it always skewed them off to by 100 px or something. so fraking annoying.

Demid
09/30/2010 10:23 AM by
Demid

To move a lost window back to the monitor without UltraMon and similar programs just right click on the program in the taskbar, use move command, move mouse back to the monitor and press left or right arrow in the keyboard. The window will jump under the cursor.

Comments have been closed on this topic.