0
我的代碼:如何在Windows窗體應用程序中嵌入記事本++以及如何控制它?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private const int WM_SYSCOMMAND = 274; private const int SC_MAXIMIZE = 61488;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private void button1_Click(object sender, EventArgs e)
{
Process proc;
proc = Process.Start("Notepad++.exe");
proc.WaitForInputIdle();
SetParent(proc.MainWindowHandle,panel1.Handle);
//SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
當我執行notepad.exe
,而不是notepad++.exe
,它工作正常。正常的記事本出現在Windows Form
的面板中。但是當我使用notepad++.exe
時,它在面板內部看不到,而是在外面作爲不同的窗口打開。我不想要這個。我的首選是notepad++
被嵌入面板我的Windows Form
,通過它,我想控制notepad++
。
我試過你的代碼,它工作正常。記事本++的主窗口在面板上浮動,而不是單獨的窗口。我使用最新版本的Notepad ++。 – 2014-10-08 06:01:55
要瘋狂的巫師:::你現在使用的記事本++版本? – Anitha 2014-10-08 06:08:29
我現在使用v6.6.9。 – 2014-10-08 06:10:43