Embedd notepad++ in my windows form. Through which i want to control notepad++ with my own function.
So far i did,
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam);
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SendMessage(int hWnd, int Msg, int wparam,
int lparam);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
extern static IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, [In] string lpClassName, [In] string lpWindowName);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
extern static int SendMessageGetTextLength(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
public Process proc;
private void Form1_Load(object sender, EventArgs e)
{
Process[] pProcess = System.Diagnostics.Process.GetProcessesByName();
foreach (Process p in pProcess)
{
p.Kill();
}
proc = Process.Start("notepad++.EXE");
proc.WaitForInputIdle();
Thread.Sleep(200);
SetParent(proc.MainWindowHandle, splitContainer1.Panel2.Handle);
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
internal void replaceToolStripMenuItem_Click(object sender, EventArgs e)
{
SetForegroundWindow(proc.MainWindowHandle);
Win32.SendMessage(proc.MainWindowHandle, SciMsg.SCI_INSERTTEXT,0, "Hello, Notepad++... from .NET!");
}
i cant edit or insert any text to my notepad++ panel in windows form.
Could anyone help me?