自定义消息的处理(转)
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;
}
}
}
}
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;
}
}
}
}
相关文章推荐
- Qt5_自定义处理Windows消息函数
- 自定义消息的处理
- 在MFC中,发送并处理自定义消息
- 自定义消息发送与处理及获取枚举名称
- VC++如何处理自定义消息
- 利用自定义消息处理函数的WPARAM或LPARAM参数传递指针
- C# 收发和处理自定义的WINDOWS消息
- MFC中自定义消息方法及如何得到消息处理函数的返回值
- vc 添加自定义消息及消息处理函数分5步
- 啊Ran讲微信开发(.net) :订阅号+自定义服务器(URL接入,文本消息处理)
- 添加自定义消息处理
- 处理自定义消息
- CreateWindowEx()自定义窗口句柄,消息处理
- 利用自定义消息处理函数的WPARAM或LPARAM参数传递指针
- 61、PasteEditText - 自定义的EditText,用来处理复制粘贴的消息
- abap系统消息处理与自定义消息处理
- 在.net(C# or vb.net)中如何用户自定义消息,并在窗体中处理这些消息
- VC++如何处理自定义消息
- C++Builder 自定义消息 处理 总结
- C# 收发和处理自定义的WINDOWS消息