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 Form重载WindowProc、WndProc 截获消息的更多相关文章

  1. c++builder 重载WindowProc、WndProc 截获消息

    c++builder 重载WindowProc.WndProc 截获消息 方法一WindowProc void __fastcall  myWindowProc(Messages::TMessage ...

  2. c++builder 重载WindowProc、WndProc 截获消息(比Delphi多一个Message Map方法)

    c++builder 重载WindowProc.WndProc 截获消息 方法一WindowProc void __fastcall  myWindowProc(Messages::TMessage ...

  3. Form开发:字段关系-消息-快速编码-参数和系统变量

     1.字段关系  清除依赖字段:在挂LOV的名称字段的WHEN-VALIDATE-ITEM调用:app_field.clear_dependent_fields    设置字段依赖:在主字段的WHEN ...

  4. [Form Builder]Form中的validate验证事件

    转:http://yedward.net/?id=70 Form的validate行为可以由一个总的form级别的validation属性来控制,可以通过set_form_property来设置成PR ...

  5. WndProc Message消息解释

    public class WindowsMessage { public const int WM_NULL = 0x0000; // public const int WM_CREATE = 0x0 ...

  6. WndProc Msg 消息列表

    WM_NULL = 0x0000; WM_CREATE = 0x0001;应用程序创建一个窗口 WM_DESTROY = 0x0002;一个窗口被销毁 WM_MOVE = 0x0003;移动一个窗口 ...

  7. c# WndProc事件 消息类型

    转载:https://www.cnblogs.com/idben/p/3783997.html WM_NULL = 0x0000; WM_CREATE = 0x0001;应用程序创建一个窗口 WM_D ...

  8. Delphi中的消息截获(六种方法:Hook,SubClass,Override WndProc,Message Handler,RTTI,Form1.WindowProc:=@myfun)good

    Windows是一个基于消息驱动的系统,因此,在很多时候,我们需要截获一些消息然后自己进行处理.而VCL系统又有一些特定的消息.下面对我所了解的delphi环境中截获消息进行一些总结.      就个 ...

  9. 结合windows消息系统理解C#中WndProc函数和DefWndProc函数

    Windows消息系统由3部分组成:     1.消息队列.Windows应用程序的消息是由Windows统一在一个消息队列中管理的.     2.消息循环.应用程序从Windows消息队列中获得自己 ...

随机推荐

  1. Oracle的导出和导入

    (摘自:http://www.cnblogs.com/mchina/archive/2012/09/12/2678093.html) 数据库的备份操作是在整个项目运行中最重要的工作之一. 一.数据的导 ...

  2. linux时间管理 之 jiffies

    1.jiffies 又称时钟滴答,是一个全局变量,它的值在系统引导的时候初始化为0,在时钟中断初始化完成后,每次时钟中断发生,在时钟中断处理例程中都会将jiffies的值 +1. jiffies_64 ...

  3. for-in 的坑

    for-in 循环的下标为字符串,不是数字 var ar=[13,2,13,14]; function isSort(ar){ for(var i in ar){ console.log(i+':'+ ...

  4. EL表达式可以直接放在url的“ ”里面

    <div class="hc-prm-search search flr"> <form action="/userCenter/projectInfo ...

  5. 【转】C#中的线程 入门

    Keywords:C# 线程 Source:http://www.albahari.com/threading/ Author: Joe Albahari Translator: Swanky Wu ...

  6. fn project 打包Function

      Option 1 (recommended): Use the fn cli tool We recommend using the fn cli tool which will handle a ...

  7. centos安装PHP-pdo支持pdo

    #yum install php-pdo phpinfo()查看PDO

  8. 详细的nginx.conf中文资料整理

    整理来源: https://blog.csdn.net/tjcyjd/article/details/50695922 整理结果 Nginx的配置文件nginx.conf配置详解如下: #Nginx用 ...

  9. 分布式缓存系统 Memcached 状态机之网络数据读取与解析

    整个状态机的基本流程如下图所示,后续分析将按该流程来进行. 接上节分解,主线程将接收的连接socket分发给了某工作线程,然后工作线程从任务队列中取出该连接socket的CQ_ITEM,开始处理该连接 ...

  10. LevelDB Cache实现机制分析

    几天前淘宝量子恒道在博客上分析了HBase的Cache机制,本篇文章,结合LevelDB 1.7.0版本的源码,分析下LevelDB的Cache机制. 概述 LevelDB是Google开源的持久化K ...