A subtlety in restoring previous window position

Raymond Chen

A common feature for many applications is to record their screen location when they shut down and reopen at that location when relaunched. If implemented naively, a program merely restores from its previous position unconditionally. You run into usability problems with this naive implementation. If a user runs two copies of your program, the two windows end up in exactly the same place on the screen. Unless the user paid close attention to their taskbar, it looks like running the second copy had no effect. Now things get interesting. Depending on what the program does, the second copy may encounter a sharing violation, or it may merely open a second copy of the document for editing, or two copies of the song may start playing, resulting in a strange echo effect since the two copies are out of sync. Even more fun is if the user hits the Stop button and the music keeps playing! Why? Because only the second copy of the playback was stopped. The first copy is still running. I know one user who not infrequently gets as many as four copies of a multimedia title running, resulting in a horrific cacophany as they all play their attract music simultaneously, followed by mass confusion as the user tries to fix the problem, which usually consists of hammering the “Stop” button on the topmost copy. This stops the topmost instance, but the other three are still running… If a second copy of the document is opened, the user may switch away from the editor, then switch back to the first instance, and think that all the changes were lost. Or the user may fail to notice this and make a conflicting set of changes to the first instance. Then all sorts of fun things happen when the two copies of the same document are saved.

Moral of the story: If your program saves and restores its screen position, you may want to check if a copy of the program is already running at that screen position. If so, then move your second window somewhere else so that it doesn’t occupy exactly the same coordinates.

0 comments

Discussion is closed.

Feedback usabilla icon