zoukankan      html  css  js  c++  java
  • 通过TApplicationEvents响应消息

    1

    源代码:
    ------------------------------------------------------------------------

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, AppEvnts;

    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        ApplicationEvents1: TApplicationEvents;
        procedure FormCreate(Sender: TObject);
        procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Memo1.Clear;
    end;

    {响应 WM_MOUSEMOVE 以外的所有消息}
    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
      if Msg.message <> WM_MOUSEMOVE then
        Memo1.Lines.Add('$' + IntToHex(Msg.message, 4));
    end;

    end.

    界面代码:
    ---------------------------------------------------------------------

    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'TApplicationEvents'
      ClientHeight = 215
      ClientWidth = 325
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Memo1: TMemo
        Left = 4
        Top = 8
        Width = 313
        Height = 161
        Lines.Strings = (
          'Memo1')
        TabOrder = 0
      end
      object ApplicationEvents1: TApplicationEvents
        OnMessage = ApplicationEvents1Message
        Left = 40
        Top = 152
      end
    end

  • 相关阅读:
    Luogu-P2295 MICE
    Luogu-P2627 修剪草坪
    Loj-10176-最大连续和
    Luogu-P1886 滑动窗口
    Luogu-P3807 【模板】卢卡斯定理
    Luogu-P1879 [USACO06NOV]玉米田Corn Fields
    Luogu-P1896 [SCOI2005]互不侵犯
    Loj-SGU 223-国王
    Luogu-P2657 [SCOI2009]windy数
    素数
  • 原文地址:https://www.cnblogs.com/hackpig/p/1668221.html
Copyright © 2011-2022 走看看