小编Jde*_*ith的帖子

在 C# 中向 Notepad++ 发送消息

当我尝试将文本从 RichTextBox 发送到 Notepad++ 时,它仅发送文本的第一个字母。因此,如果我在Send this to Notepad++Notepad++ 的文本框中显示的是S.

这是我的代码

[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    [DllImport("User32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
    private void button2_Click(object sender, EventArgs e)
    {

        Process[] notepads = Process.GetProcessesByName("notepad++");
        if (notepads.Length == 0) return;
        if (notepads[0] != null)
        {
            IntPtr child = FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Scintilla", null);
            SendMessage(child, 0x000C, 0, RichTextBox1.Text);
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# sendmessage

3
推荐指数
1
解决办法
6270
查看次数

标签 统计

c# ×1

sendmessage ×1