• 子类化窗口控件的窗口过程(系统级替换,与直接替换控件的WndProc方法不是一回事)


    要说灵活性,自然是比不上Delphi自带的覆盖WndProc,或者替换WndProc方法。

    unit   Unit1;  
       
      interface  
       
      uses  
          Windows,   Messages,   SysUtils,   Classes,   Controls,   Forms,   Dialogs,   StdCtrls;  
       
      type  
          TForm1   =   class(TForm)  
              Edit1:   TEdit;  
              procedure   FormCreate(Sender:   TObject);  
          private  
              FOldWndProc,   FNewWndProc:   TFarProc;  
              procedure   WindowProc(var   Message:   TMessage);  
          end;  
       
      var  
          Form1:   TForm1;  
       
      implementation  
       
      {$R   *.dfm}  
       
      procedure   TForm1.WindowProc(var   Message:   TMessage);  
      begin  
          Message.Result   :=   CallWindowProc(FOldWndProc,   Edit1.Handle,   Message.Msg,  
                Message.WParam,   Message.LParam);  
      end;  
       
      procedure   TForm1.FormCreate(Sender:   TObject);  
      begin  
          FNewWndProc   :=   MakeObjectInstance(WindowProc);  
          FOldWndProc   :=   Pointer(GetWindowLong(Edit1.Handle,   GWL_WNDPROC));  
          SetWindowLong(Edit1.Handle,   GWL_WNDPROC,   LongInt(FNewWndProc));  
      end;  
       
      end.
     
    // 其它消息做默认处理
      Result := DefWindowProc(hWnd, uMsg, wParam, lParam);

    参考:http://www.cnblogs.com/key-ok/p/3380556.html

  • 相关阅读:
    网络安全协议(1)
    CG-CTF(6)
    CG-CTF(5)
    CG-CTF(4)
    CG-CTF(3)
    MAC地址欺骗(原理及实验)
    CG-CTF(2)
    CG-CTF(1)
    【转载】Spring Boot【快速入门】2019.05.19
    【编程大系】Java资源汇总
  • 原文地址:https://www.cnblogs.com/findumars/p/4748599.html
Copyright © 2020-2023  润新知