110,539
社区成员
发帖
与我相关
我的任务
分享
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private const int WM_USER = 0x0400;
private const int WM_BUTTON1 = WM_USER + 1;
private const int WM_BUTTON2 = WM_USER + 2;
private const int WM_BUTTON3 = WM_USER + 3;
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle,WM_BUTTON1,0,0);
}
private void button2_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_BUTTON2, 0, 0);
}
private void button3_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_BUTTON3, 0, 0);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_BUTTON1:
MessageBox.Show("1");
break;
case WM_BUTTON2:
MessageBox.Show("2");
break;
case WM_BUTTON3:
MessageBox.Show("3");
break;
}
base.WndProc(ref m);
}