zoukankan      html  css  js  c++  java
  • 学习 Message(8): 使用不同的消息结构


    下面是同样的四段程序, 但分别使用了不同的三种消息结构: TWMMouseMove、TWMMouse、TMessage
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TForm1 = class(TForm)
      protected
        procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.WMMouseMove(var Message: TWMMouseMove);
    var
      x,y: Integer;
    begin
      x := Message.XPos;
      y := Message.YPos;
      Text := Format('%d, %d', [x,y]);
    end;
    
    end.
    
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TForm1 = class(TForm)
      protected
        procedure WMMouseMove(var Message: TWMMouse); message WM_MOUSEMOVE;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.WMMouseMove(var Message: TWMMouse);
    var
      x,y: Integer;
    begin
      x := Message.XPos;
      y := Message.YPos;
      Text := Format('%d, %d', [x,y]);
    end;
    
    end.
    
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TForm1 = class(TForm)
      protected
        procedure WMMouseMove(var Message: TMessage); message WM_MOUSEMOVE;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.WMMouseMove(var Message: TMessage);
    var
      x,y: Integer;
    begin
      x := Message.LParamLo;
      y := Message.LParamHi;
      Text := Format('%d, %d', [x,y]);
    end;
    
    end.
    
  • 相关阅读:
    Python多线程_thread和Threading
    Python多线程_thread和Threading
    ICMP协议
    ICMP协议
    Python中的Pexpect模块的简单使用
    Python中的Pexpect模块的简单使用
    Python中math和cmath模块的使用
    Python中math和cmath模块的使用
    Python中sys模块的使用
    Python模块化编程
  • 原文地址:https://www.cnblogs.com/del/p/1321559.html
Copyright © 2011-2022 走看看