You need total 3 steps to define your message
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar);
public const int UserMsg = 0x0600;
SendMessage(this.Parent.Handle, UserMsg, (IntPtr)1, (IntPtr)1);
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0600:
break;
default:
base.WndProc(ref m);
break;
}
}
本文介绍了如何使用 C# 在 Windows 应用程序中定义并处理自定义消息。通过 DLL 导入 user32.dll 中的 SendMessage 函数,并定义了一个自定义消息 UserMsg,演示了如何发送自定义消息及在窗口过程 WndProc 中捕获和处理该消息。
1535

被折叠的 条评论
为什么被折叠?



