All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SQL Server 索引基础知识(1)--- 记录数据的基本格式_[SQL Server教程]
预载入和javascript,Image()对象_JavaScript技术_编程技术
在动态网页技术PHP5中类(CLASS)的新特征_php资料_编程技术
用PHP将数据导入到Foxmail_php资料_编程技术
设置GridView的选中行效果代码_[Asp.Net教程]
VB.NET中层次数据绑定TreeView的实现_.net资料_编程技术
将输入的20041219等的数字字符串等格式化成日期型_[Asp.Net教程]
C#文件处理技术:文件的读取使用方法
javascript应用实例:点出统计器_JavaScript技术_编程技术
PHP配置链接access数据库_[PHP教程]
Reading number is top 10 pictures
Street street fighting
你的钱干净吗?
Japanese snow monkeys in the hot spring to keep warm, close their eyes to enjoy
赵惟依写真2
无题
这才是真正的人体艺术5
China's first snake village1
China's first snake village2
星星命名法则
A man's favorite things4
Download software ranking
The hero
Unix video tutorial14
Unix video tutorial6
Boxer's Top ten classic battle2
Boxer's Top ten classic battle7
Boxer Classic video1
传奇私服架设教程
Unix video tutorial19
Boxer Classic video2
matrix3
delv published in(发表于) 2014/1/6 9:08:29 Edit(编辑)
Winform中在Form上截取消息的两种方法_[Asp.Net教程]

Winform中在Form上截取消息的两种方法_[Asp.Net教程]

Winform中在Form上截取消息的两种方法_[Asp.Net教程]

比较常用的是重载Form的DefWndProc方法,例如截取鼠标按下的消息:

protected override void DefWndProc(ref Message m)
{
if ( m.Msg == 0x0201 )
{
MessageBox.Show(m.Msg.ToString());
}
else
{
base.DefWndProc (ref m);
}
}


  还可以通过另一种办法,使用IMessageFilter 接口:


public class MessageFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 0x0201)
{
MessageBox.Show("WM_LBUTTONDOWN is: " + m.Msg);
return true;
}
return false;
}


}


  然后使用Application.AddMessageFilter方法,例如:


private static MessageFilter msgFliter = new MessageFilter();


  在Main方法中注册消息筛选器:


Application.AddMessageFilter(msgFliter);


  如果要取消注册,可以调用Application.RemoveMessageFilter方法







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.