2
I need to open an external program to stay in the second screen. I need it to be exactly embedded in the second monitor.
Let’s say I want to open the notepad, I don’t want to open it on the first monitor, but on the second monitor. That’s my goal.
I’m taking the information from the second screen to move the Notepad to it. Note that the second screen is in the form of array[1]
, that array
is the information of the second extended screen. To execute the code below, you need to extend the screen and leave the Notepad open.
public Form1() {
InitializeComponent();
Rectangle area = Screen.AllScreens[1].WorkingArea;
ScreenMove(area.X, area.Y, area.Width, area.Height);
}
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOZORDER = 0x0004;
public static void ScreenMove(int x, int y, int lx, int ly) {
IntPtr hWnd = FindWindow("Notepad", null);
if (hWnd != IntPtr.Zero) {
SetWindowPos(hWnd, IntPtr.Zero, x, y, lx, ly, SWP_NOSIZE | SWP_NOZORDER);
}
}
That’s what I can’t, there must be some way to move the Otepad window to the second screen, but I don’t know which.
Bruno Where do I get the Winapi class?
– sYsTeM
@System Oops forgot about that dependency. You are here https://github.com/alex-tomin/Tomin.Tools.KioskMode/blob/master/Tomin.Tools.KioskMode/WinApi.cs
– Bruno Costa
Certinho agr, thank you very much!
– sYsTeM