Hab etwas recherchiert und konnte dann daraus das entwerfen:
C#-Quelltext
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); } |
Die Form ist 300px breit, deshalb "+300".
In der Main-Methode der Console muss man dann nur noch das aufrufen:
C#-Quelltext
1: 2:
| Form1 frm = new Form1(); frm.ShowDialog(); |
Nun habe ich nur noch ein ein Problem. Sobald ich die Form versuche zu bewegen, bewegt sie sich nur ein paar Millimeter. Die Console zieht nach und ich muss die Form mit der Maus los lassen, da sie sich nicht weiterbewegt. Erst dann kann ich wieder einen neuen Versuch starten. Dann aber wieder nur ein paar Millimeter...