c++builder 重载WindowProc、WndProc 截获消息
c++builder 重载WindowProc、WndProc 截获消息
方法一WindowProc
void __fastcall myWindowProc(Messages::TMessage &msg); //增加
Classes::TWndMethod OldWindowProc; //增加
void __fastcall TForm1::myWindowProc(Messages::TMessage &msg)
{
if (msg.Msg == WM_MOUSEWHEEL)
{
//::MessageBox(NULL,"OK","Message",0); //测试
Caption = Now();
}
else
OldWindowProc(Message);
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
OldWindowProc=Edit1->WindowProc;
Edit1->WindowProc=myWindowProc;
}
方法二 MESSAGE_MAP
class TForm1 : public TForm
{
__published: // IDE-managed Components
TEdit *Edit1;
private: // User declarations
void __fastcall OnEditMouseWell(TMessage &msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MOUSEWHEEL, TMessage, OnEditMouseWell)
END_MESSAGE_MAP(TForm) //TForm 换成TEdit
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
void __fastcall TForm1::OnEditMouseWell(TMessage &msg)
{
if(String(ActiveControl->ClassName())=="TEdit") //所有的Edit
Caption = Now(); //测试
//TForm::Dispatch(&Msg);
}
方法三 重载 WndProc
private: // User declarations
void __fastcall WndProc(Messages::TMessage &msg);
void __fastcall TForm1::WndProc(Messages::TMessage &msg)
{
if (msgMsg == WM_MOUSEWHEEL && msg.WParam )
{
Caption = Now();
}
TForm::WndProc(msg);
}
四、ApplicationEvents控件
窗体上放置ApplicationEvents1控件,在ApplicationEvents1Message事件里判断。
void __fastcall TForm3::ApplicationEvents1Message(tagMSG &Msg, bool &Handled)
{
if (Msg.hwnd == this->DBGrid1->Handle && Msg.message == WM_MOUSEWHEEL)
this->Caption = Now();
}
WM_LBUTTONDOWN
c++builder 重载WindowProc、WndProc 截获消息的更多相关文章
- c++builder 重载WindowProc、WndProc 截获消息(比Delphi多一个Message Map方法)
c++builder 重载WindowProc.WndProc 截获消息 方法一WindowProc void __fastcall myWindowProc(Messages::TMessage ...
- c++builder Form重载WindowProc、WndProc 截获消息
c++builder 重载WindowProc.WndProc 截获消息 方法一WindowProc void __fastcall myWindowProc(Messages::TMessage ...
- WndProc Message消息解释
public class WindowsMessage { public const int WM_NULL = 0x0000; // public const int WM_CREATE = 0x0 ...
- WndProc Msg 消息列表
WM_NULL = 0x0000; WM_CREATE = 0x0001;应用程序创建一个窗口 WM_DESTROY = 0x0002;一个窗口被销毁 WM_MOVE = 0x0003;移动一个窗口 ...
- c# WndProc事件 消息类型
转载:https://www.cnblogs.com/idben/p/3783997.html WM_NULL = 0x0000; WM_CREATE = 0x0001;应用程序创建一个窗口 WM_D ...
- Delphi中的消息截获(六种方法:Hook,SubClass,Override WndProc,Message Handler,RTTI,Form1.WindowProc:=@myfun)good
Windows是一个基于消息驱动的系统,因此,在很多时候,我们需要截获一些消息然后自己进行处理.而VCL系统又有一些特定的消息.下面对我所了解的delphi环境中截获消息进行一些总结. 就个 ...
- 结合windows消息系统理解C#中WndProc函数和DefWndProc函数
Windows消息系统由3部分组成: 1.消息队列.Windows应用程序的消息是由Windows统一在一个消息队列中管理的. 2.消息循环.应用程序从Windows消息队列中获得自己 ...
- MFC消息详解 (WindowProc|OnCommand|OnNotify)
1. 怎样使用MFC发送一个消息用MFC发送一个消息的方法是, 首先,应获取接收消息的CWnd类对象的指针: 然后,调用CWnd的成员函数SendMessage( ). LRESULT Res=pWn ...
- 【转】C# 重写WndProc 拦截 发送 系统消息 + windows消息常量值(1)
C# 重写WndProc 拦截 发送 系统消息 + windows消息常量值(1) #region 截获消息 /// 截获消息 处理XP不能关机问题 protected ...
随机推荐
- 【温故知新】c#异步编程模型(APM)--使用委托进行异步编程
当我们用到C#类许多耗时的函数XXX时,总会存在同名的类似BeginXXX,EndXXX这样的函数. 例如Stream抽象类的Read函数就有 public abstract int Read(byt ...
- Spring MVC文件下载
方案一: // 文件下载 @RequestMapping(value = "/downloadFile") public ResponseEntity<byte[]> ...
- bzoj2428: [HAOI2006]均分数据
模拟退火.挺好理解的.然后res打成了ans一直WA一直WA...!!!一定要注意嗷嗷嗷一定要注意嗷嗷嗷一定要注意嗷嗷嗷. 然后我就一直卡一直卡...发现最少1800次的时候就可以出解了.然后我就去调 ...
- 高性能WEB开发之Web性能测试工具推荐
Firebug: Firebug 是firefox中最为经典的开发工具,可以监控请求头,响应头,显示资源加载瀑布图: HttpWatch: httpwatch 功能类似firebug,可以监控请求头, ...
- ASP.NET MVC 4 WebAPI. Support Areas in HttpControllerSelector
This article was written for ASP.NET MVC 4 RC (Release Candidate). If you are still using Beta versi ...
- pycharm Working directory error
/***************************************************************************** * pycharm Working dir ...
- mysql无法插入中文字符解决
1. 基于可维护的角度,虽然latin1没什么问题,但是还是尽量换成utf8或者gb系列 2. 出现乱码时: SHOW VARIABLES LIKE 'character%'SHOW VARIABLE ...
- 【英语】Bingo口语笔记(58) - blow系列
- 数据结构——Java实现单向链表
结点类: /** * @author zhengbinMac * 一个OnelinkNode类的对象只表示链表中的一个结点,通过成员变量next的自引用方式实现线性表中各数据元素的逻辑关系. */ p ...
- mysql创建/删除表的例子
创建表 简单的方式 CREATE TABLE person ( number INT(11), name VARCHAR(255), birthday DATE ); 或者是 CREATE TABLE ...