1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| const int SWP_NOSIZE = 0x0001; [DllImport("kernel32.dll", ExactSpelling = true)] private static extern IntPtr GetConsoleWindow();
private static IntPtr MyConsole = GetConsoleWindow();
[DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
public static Point mainPos;
private void Form1_Move(object sender, EventArgs e) { mainPos = this.Location;
int xpos = Form1.mainPos.X + 300; int ypos = Form1.mainPos.Y; SetWindowPos(MyConsole, 0, xpos, ypos, 0, 0, SWP_NOSIZE); } |