您的位置:首页 > 其它

自定义消息的处理(转)

2008-07-21 18:38 246 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml.Xsl;
using System.Runtime.InteropServices;
namespace Test
{
public partial class Form1 : Form
{
public const int USER = 0x0600;
public const int TEST = USER + 1;
public Form1()
{
InitializeComponent();
}
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
IntPtr hWnd,   // handle to destination window
int Msg,    // message
int wParam, // first message parameter
int lParam // second message parameter
);
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, TEST, 100, 120);
}
protected override void DefWndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case TEST:
string message = string.Format("{0}====={1}", m.LParam, m.WParam);
MessageBox.Show(message);
break;
default:
base.DefWndProc(ref m);
break;
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: