October 24th, 2017

When I use Alt+PrtSc to take a screen shot of a maximized window, why does it capture a few pixels from an adjacent monitor?

On a dual-monitor system, maximize a window onto one monitor, and then use the Alt+PrtSc hotkey to capture a screen shot of that window. The resulting bitmap captures a few pixels from the adjacent monitor. Why is that?

This is a consequence of a phenomenon I discussed some time ago: Maximized windows actually extend beyond the edges of the monitor. This is done so that the main window body fills the monitor, and the borders hang off the edge. The theory is that you want to fill the screen with the useful parts of the window, and you’re not interested in the borders.

The code that handles the Alt+PrtSc hotkey captures the entire window, including the parts that hang off the monitor. On three of the sides, there is no content on the other side of the monitor, so the attempt to capture those borders fails. But on the fourth side, the screen capture code sees that the pixels are still valid, and it includes them in the bitmap even though they’re on the wrong monitor.

You might be tempted to fix this by clipping the screen shot to the current monitor, but that would result in partial screen shots in the case where the user has a window that intentionally straddles more than one monitor.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.