How do I enable a second monitor in C#?

MSDN Device Context Functions What you basically need to do: Use the EnumDisplayDevices() API call to enumerate the display devices on the system and look for those that don’t have the DISPLAY_DEVICE_ATTACHED_TO_DESKTOP flag set (this will include any mirroring devices so not all will be physical displays.) Once you’ve found the display device you’ll need … Read more

Specify monitor when opening file. (.bat)

Unless the application you’re launching has a command-line switch for it, there’s no easy way to specify on which monitor to display a window. As far as I’m aware, neither start nor notepad supports such a switch. The closest solution I’ve found is to move a window after it’s already open. Edit: user32.dll SetWindowPos() invoked … Read more

How do I ensure a form displays on the “additional” monitor in a dual monitor scenario? [duplicate]

You need to use the Screen class to find a screen that the original form is not on, then set the second form’s Location property based on that screen’s Bounds. For example: var myScreen = Screen.FromControl(originalForm); var otherScreen = Screen.AllScreens.FirstOrDefault(s => !s.Equals(myScreen)) ?? myScreen; otherForm.Left = otherScreen.WorkingArea.Left + 120; otherForm.Top = otherScreen.WorkingArea.Top + 120; This … Read more

Going fullscreen on secondary monitor

Extension method to Maximize a window to the secondary monitor (if there is one). Doesn’t assume that the secondary monitor is System.Windows.Forms.Screen.AllScreens[2]; using System.Linq; using System.Windows; namespace ExtendedControls { static public class WindowExt { // NB : Best to call this function from the windows Loaded event or after showing the window // (otherwise window … Read more

Take screenshot of multiple desktops of all visible applications and forms

i tried GetDesktopWindow() function but it doesn’t work properly. Of course not. The GetDesktopWindow function returns a handle to the desktop window. It doesn’t have anything to do with capturing an image of that window. Besides, the desktop window is not the same thing as “the entire screen”. It refers specifically to the desktop window. … Read more

window.open() on a multi-monitor/dual-monitor system – where does window pop up?

Result of “window.open dual-screen” search revealed this fancy nugget: Dual Monitors and Window.open “When the user clicks on a link that opens a new window using window.open. Make the window appear on the same monitor as its’ parent.” // Find Left Boundry of the Screen/Monitor function FindLeftScreenBoundry() { // Check if the window is off … Read more