79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Remontor
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
|
|
|
|
private const int SWP_NOOWNERZORDER = 0x200;
|
|
private const int SWP_NOREDRAW = 0x8;
|
|
private const int SWP_NOZORDER = 0x4;
|
|
private const int SWP_SHOWWINDOW = 0x0040;
|
|
private const int WS_EX_MDICHILD = 0x40;
|
|
private const int SWP_FRAMECHANGED = 0x20;
|
|
private const int SWP_NOACTIVATE = 0x10;
|
|
private const int SWP_ASYNCWINDOWPOS = 0x4000;
|
|
private const int SWP_NOMOVE = 0x2;
|
|
private const int SWP_NOSIZE = 0x1;
|
|
private const int GWL_STYLE = (-16);
|
|
private const int WS_VISIBLE = 0x10000000;
|
|
private const int WM_CLOSE = 0x10;
|
|
private const int WS_CHILD = 0x40000000;
|
|
|
|
Process p1;
|
|
Process p;
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
p1 = Process.Start("notepad");
|
|
//Thread.Sleep(500); // Allow the process to open it's window
|
|
p1.WaitForInputIdle();
|
|
SetParent(p1.MainWindowHandle, panel1.Handle);
|
|
SetWindowLong(p1.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
|
|
MoveWindow(p1.MainWindowHandle, panel1.Bounds.X, panel1.Bounds.Y - 24, panel1.Bounds.Width, panel1.Bounds.Height, true);
|
|
p = Process.Start("notepad");
|
|
//Thread.Sleep(500); // Allow the process to open it's window
|
|
p.WaitForInputIdle();
|
|
SetParent(p.MainWindowHandle, panel3.Handle);
|
|
SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
|
|
MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y - 24, panel3.Bounds.Width, panel3.Bounds.Height, true);
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
panel1.Visible =! panel1.Visible;
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
panel3.Visible =! panel3.Visible;
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|
|
[DllImport("user32.dll")]
|
|
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
|
[DllImport("user32.dll")]
|
|
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
|
|
|
|
private void tabControl1_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
MoveWindow(p1.MainWindowHandle, panel1.Bounds.X, panel1.Bounds.Y - 24, panel1.Bounds.Width, panel1.Bounds.Height, true);
|
|
MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y - 24, panel3.Bounds.Width, panel3.Bounds.Height, true);
|
|
}
|
|
}
|
|
}
|
|
|