Главная страницаОбратная связьКарта сайта

Мониторинг сообщений


unit Mlist;

interface

uses
  SysUtils, Classes, Messages, Controls;

var
  MsgList: TStringList;

function GetMessageName (Msg: Integer): string;

implementation

function GetMessageName (Msg: Integer): string;
var
  N: Integer;
begin
  N := MsgList.IndexOfObject (TObject(Msg));
  if N >= 0 then
    Result := MsgList.Strings [N]
  else if (Msg >= wm_User) and
      (Msg <= $7FFF) then
    Result := Format (
      "wm_User message (%d)", [Msg])
  else
    Result := Format (
      "Undocumented (%d)", [Msg]);
end;

initialization
  MsgList := TStringList.Create;
  MsgList.AddObject ("wm_Null", TObject($0000));
  MsgList.AddObject ("wm_Create", TObject($0001));
  MsgList.AddObject ("wm_Destroy", TObject($0002));
  MsgList.AddObject ("wm_Move", TObject($0003));
  MsgList.AddObject ("wm_Size", TObject($0005));
  MsgList.AddObject ("wm_Activate", TObject($0006));
  MsgList.AddObject ("wm_SetFocus", TObject($0007));
  MsgList.AddObject ("wm_KillFocus", TObject($0008));
  MsgList.AddObject ("wm_Enable", TObject($000A));
  MsgList.AddObject ("wm_SetRedraw", TObject($000B));
  MsgList.AddObject ("wm_SetText", TObject($000C));
  MsgList.AddObject ("wm_GetText", TObject($000D));
  MsgList.AddObject ("wm_GetTextLength", TObject($000E));
  MsgList.AddObject ("wm_Paint", TObject($000F));
  MsgList.AddObject ("wm_Close", TObject($0010));
  MsgList.AddObject ("wm_QueryEndSession", TObject($0011));
  MsgList.AddObject ("wm_Quit", TObject($0012));
  MsgList.AddObject ("wm_QueryOpen", TObject($0013));
  MsgList.AddObject ("wm_EraseBkGnd", TObject($0014));
  MsgList.AddObject ("wm_SysColorChange", TObject($0015));
  MsgList.AddObject ("wm_EndSession", TObject($0016));
  MsgList.AddObject ("wm_SystemError", TObject($0017));
  MsgList.AddObject ("wm_ShowWindow", TObject($0018));
  MsgList.AddObject ("wm_CtlColor", TObject($0019));
  MsgList.AddObject ("wm_WinIniChange", TObject($001A));
  MsgList.AddObject ("wm_DevModeChange", TObject($001B));
  MsgList.AddObject ("wm_ActivateApp", TObject($001C));
  MsgList.AddObject ("wm_FontChange", TObject($001D));
  MsgList.AddObject ("wm_TimeChange", TObject($001E));
  MsgList.AddObject ("wm_CancelMode", TObject($001F));
  MsgList.AddObject ("wm_SetCursor", TObject($0020));
  MsgList.AddObject ("wm_MouseActivate", TObject($0021));
  MsgList.AddObject ("wm_ChildActivate", TObject($0022));
  MsgList.AddObject ("wm_QueueSync", TObject($0023));
  MsgList.AddObject ("wm_GetMinMaxInfo", TObject($0024));
  MsgList.AddObject ("wm_PaintIcon", TObject($0026));
  MsgList.AddObject ("wm_IconEraseBkGnd", TObject($0027));
  MsgList.AddObject ("wm_NextDlgCtl", TObject($0028));
  MsgList.AddObject ("wm_SpoolerStatus", TObject($002A));
  MsgList.AddObject ("wm_DrawItem", TObject($002B));
  MsgList.AddObject ("wm_MeasureItem", TObject($002C));
  MsgList.AddObject ("wm_DeleteItem", TObject($002D));
  MsgList.AddObject ("wm_VKeyToItem", TObject($002E));
  MsgList.AddObject ("wm_CharToItem", TObject($002F));
  MsgList.AddObject ("wm_SetFont", TObject($0030));
  MsgList.AddObject ("wm_GetFont", TObject($0031));
  MsgList.AddObject ("wm_QueryDragIcon", TObject($0037));
  MsgList.AddObject ("wm_CompareItem", TObject($0039));
  MsgList.AddObject ("wm_Compacting", TObject($0041));
  MsgList.AddObject ("wm_CommNotify", TObject($0044));
  MsgList.AddObject ("wm_WindowPosChanging", TObject($0046));
  MsgList.AddObject ("wm_WindowPosChanged", TObject($0047));
  MsgList.AddObject ("wm_Power", TObject($0048));
  MsgList.AddObject ("wm_CopyData", TObject($004A));
  MsgList.AddObject ("wm_CancelJournal", TObject($004B));
  MsgList.AddObject ("wm_Notify", TObject($004E));
  MsgList.AddObject ("wm_StyleChanging", TObject($007C));
  MsgList.AddObject ("wm_StyleChanged", TObject($007D));
  MsgList.AddObject ("wm_GetIcon", TObject($007F));
  MsgList.AddObject ("wm_SetIcon", TObject($0080));
  MsgList.AddObject ("wm_NCCreate", TObject($0081));
  MsgList.AddObject ("wm_NCDestroy", TObject($0082));
  MsgList.AddObject ("wm_NCCalcSize", TObject($0083));
  MsgList.AddObject ("wm_NCHitTest", TObject($0084));
  MsgList.AddObject ("wm_NCPaint", TObject($0085));
  MsgList.AddObject ("wm_NCActivate", TObject($0086));
  MsgList.AddObject ("wm_GetDlgCode", TObject($0087));
  MsgList.AddObject ("wm_NCMouseMove", TObject($00A0));
  MsgList.AddObject ("wm_NCLButtonDown", TObject($00A1));
  MsgList.AddObject ("wm_NCLButtonUp", TObject($00A2));
  MsgList.AddObject ("wm_NCLButtonDblClk", TObject($00A3));
  MsgList.AddObject ("wm_NCRButtonDown", TObject($00A4));
  MsgList.AddObject ("wm_NCRButtonUp", TObject($00A5));
  MsgList.AddObject ("wm_NCRButtonDblClk", TObject($00A6));
  MsgList.AddObject ("wm_NCMButtonDown", TObject($00A7));
  MsgList.AddObject ("wm_NCMButtonUp", TObject($00A8));
  MsgList.AddObject ("wm_NCMButtonDblClk", TObject($00A9));
  MsgList.AddObject ("wm_KeyDown", TObject($0100));
  MsgList.AddObject ("wm_KeyUp", TObject($0101));
  MsgList.AddObject ("wm_Char", TObject($0102));
  MsgList.AddObject ("wm_DeadChar", TObject($0103));
  MsgList.AddObject ("wm_SysKeyDown", TObject($0104));
  MsgList.AddObject ("wm_SysKeyUp", TObject($0105));
  MsgList.AddObject ("wm_SysChar", TObject($0106));
  MsgList.AddObject ("wm_SysDeadChar", TObject($0107));
  MsgList.AddObject ("wm_InitDialog", TObject($0110));
  MsgList.AddObject ("wm_Command", TObject($0111));
  MsgList.AddObject ("wm_SysCommand", TObject($0112));
  MsgList.AddObject ("wm_Timer", TObject($0113));
  MsgList.AddObject ("wm_HScroll", TObject($0114));
  MsgList.AddObject ("wm_VScroll", TObject($0115));
  MsgList.AddObject ("wm_InitMenu", TObject($0116));
  MsgList.AddObject ("wm_InitMenuPopup", TObject($0117));
  MsgList.AddObject ("wm_MenuSelect", TObject($011F));
  MsgList.AddObject ("wm_MenuChar", TObject($0120));
  MsgList.AddObject ("wm_EnterIdle", TObject($0121));
  MsgList.AddObject ("wm_CtlColorMsgbox", TObject($0132));
  MsgList.AddObject ("wm_CtlColorEdit", TObject($0133));
  MsgList.AddObject ("wm_CtlColorListbox", TObject($0134));
  MsgList.AddObject ("wm_CtlColorBtn", TObject($0135));
  MsgList.AddObject ("wm_CtlColorDlg", TObject($0136));
  MsgList.AddObject ("wm_CtlColorScrollbar", TObject($0137));
  MsgList.AddObject ("wm_CtlColorStatic", TObject($0138));
  MsgList.AddObject ("wm_MouseMove", TObject($0200));
  MsgList.AddObject ("wm_LButtonDown", TObject($0201));
  MsgList.AddObject ("wm_LButtonUp", TObject($0202));
  MsgList.AddObject ("wm_LButtonDblClk", TObject($0203));
  MsgList.AddObject ("wm_RButtonDown", TObject($0204));
  MsgList.AddObject ("wm_RButtonUp", TObject($0205));
  MsgList.AddObject ("wm_RButtonDblClk", TObject($0206));
  MsgList.AddObject ("wm_MButtonDown", TObject($0207));
  MsgList.AddObject ("wm_MButtonUp", TObject($0208));
  MsgList.AddObject ("wm_MButtonDblClk", TObject($0209));
  MsgList.AddObject ("wm_ParentNotify", TObject($0210));
  MsgList.AddObject ("wm_MDICreate", TObject($0220));
  MsgList.AddObject ("wm_MDIDestroy", TObject($0221));
  MsgList.AddObject ("wm_MDIActivate", TObject($0222));
  MsgList.AddObject ("wm_MDIRestore", TObject($0223));
  MsgList.AddObject ("wm_MDINext", TObject($0224));
  MsgList.AddObject ("wm_MDIMaximize", TObject($0225));
  MsgList.AddObject ("wm_MDITile", TObject($0226));
  MsgList.AddObject ("wm_MDICascade", TObject($0227));
  MsgList.AddObject ("wm_MDIIconArrange", TObject($0228));
  MsgList.AddObject ("wm_MDIGetActive", TObject($0229));
  MsgList.AddObject ("wm_MDISetMenu", TObject($0230));
  MsgList.AddObject ("wm_DropFiles", TObject($0233));
  MsgList.AddObject ("wm_MDIRefreshMenu", TObject($0234));
  MsgList.AddObject ("wm_Cut", TObject($0300));
  MsgList.AddObject ("wm_Copy", TObject($0301));
  MsgList.AddObject ("wm_Paste", TObject($0302));
  MsgList.AddObject ("wm_Clear", TObject($0303));
  MsgList.AddObject ("wm_Undo", TObject($0304));
  MsgList.AddObject ("wm_RenderFormat", TObject($0305));
  MsgList.AddObject ("wm_RenderAllFormats", TObject($0306));
  MsgList.AddObject ("wm_DestroyClipboard", TObject($0307));
  MsgList.AddObject ("wm_DrawClipboard", TObject($0308));
  MsgList.AddObject ("wm_PaintClipboard", TObject($0309));
  MsgList.AddObject ("wm_VScrollClipboard", TObject($030A));
  MsgList.AddObject ("wm_SizeClipboard", TObject($030B));
  MsgList.AddObject ("wm_AskCBFormatName", TObject($030C));
  MsgList.AddObject ("wm_ChangeCBChain", TObject($030D));
  MsgList.AddObject ("wm_HScrollClipboard", TObject($030E));
  MsgList.AddObject ("wm_QueryNewPalette", TObject($030F));
  MsgList.AddObject ("wm_PaletteIsChanging", TObject($0310));
  MsgList.AddObject ("wm_PaletteChanged", TObject($0311));
  // Delphi notifications and messages
  MsgList.AddObject ("CM_ACTIVATE", TObject(CM_BASE + 0));
  MsgList.AddObject ("CM_DEACTIVATE", TObject(CM_BASE + 1));
  MsgList.AddObject ("CM_GOTFOCUS", TObject(CM_BASE + 2));
  MsgList.AddObject ("CM_LOSTFOCUS", TObject(CM_BASE + 3));
  MsgList.AddObject ("CM_CANCELMODE", TObject(CM_BASE + 4));
  MsgList.AddObject ("CM_DIALOGKEY", TObject(CM_BASE + 5));
  MsgList.AddObject ("CM_DIALOGCHAR", TObject(CM_BASE + 6));
  MsgList.AddObject ("CM_FOCUSCHANGED", TObject(CM_BASE + 7));
  MsgList.AddObject ("CM_PARENTFONTCHANGED", TObject(CM_BASE + 8));
  MsgList.AddObject ("CM_PARENTCOLORCHANGED", TObject(CM_BASE + 9));
  MsgList.AddObject ("CM_HITTEST", TObject(CM_BASE + 10));
  MsgList.AddObject ("CM_VISIBLECHANGED", TObject(CM_BASE + 11));
  MsgList.AddObject ("CM_ENABLEDCHANGED", TObject(CM_BASE + 12));
  MsgList.AddObject ("CM_COLORCHANGED", TObject(CM_BASE + 13));
  MsgList.AddObject ("CM_FONTCHANGED", TObject(CM_BASE + 14));
  MsgList.AddObject ("CM_CURSORCHANGED", TObject(CM_BASE + 15));
  MsgList.AddObject ("CM_CTL3DCHANGED", TObject(CM_BASE + 16));
  MsgList.AddObject ("CM_PARENTCTL3DCHANGED", TObject(CM_BASE + 17));
  MsgList.AddObject ("CM_TEXTCHANGED", TObject(CM_BASE + 18));
  MsgList.AddObject ("CM_MOUSEENTER", TObject(CM_BASE + 19));
  MsgList.AddObject ("CM_MOUSELEAVE", TObject(CM_BASE + 20));
  MsgList.AddObject ("CM_MENUCHANGED", TObject(CM_BASE + 21));
  MsgList.AddObject ("CM_APPKEYDOWN", TObject(CM_BASE + 22));
  MsgList.AddObject ("CM_APPSYSCOMMAND", TObject(CM_BASE + 23));
  MsgList.AddObject ("CM_BUTTONPRESSED", TObject(CM_BASE + 24));
  MsgList.AddObject ("CM_SHOWINGCHANGED", TObject(CM_BASE + 25));
  MsgList.AddObject ("CM_ENTER", TObject(CM_BASE + 26));
  MsgList.AddObject ("CM_EXIT", TObject(CM_BASE + 27));
  MsgList.AddObject ("CM_DESIGNHITTEST", TObject(CM_BASE + 28));
  MsgList.AddObject ("CM_ICONCHANGED", TObject(CM_BASE + 29));
  MsgList.AddObject ("CM_WANTSPECIALKEY", TObject(CM_BASE + 30));
  MsgList.AddObject ("CM_INVOKEHELP", TObject(CM_BASE + 31));
  MsgList.AddObject ("CM_WINDOWHOOK", TObject(CM_BASE + 32));
  MsgList.AddObject ("CM_RELEASE", TObject(CM_BASE + 33));
  MsgList.AddObject ("CM_SHOWHINTCHANGED", TObject(CM_BASE + 34));
  MsgList.AddObject ("CM_PARENTSHOWHINTCHANGED", TObject(CM_BASE + 35));
  MsgList.AddObject ("CM_SYSCOLORCHANGE", TObject(CM_BASE + 36));
  MsgList.AddObject ("CM_WININICHANGE", TObject(CM_BASE + 37));
  MsgList.AddObject ("CM_FONTCHANGE", TObject(CM_BASE + 38));
  MsgList.AddObject ("CM_TIMECHANGE", TObject(CM_BASE + 39));
  MsgList.AddObject ("CM_TABSTOPCHANGED", TObject(CM_BASE + 40));
  MsgList.AddObject ("CM_UIACTIVATE", TObject(CM_BASE + 41));
  MsgList.AddObject ("CM_UIDEACTIVATE", TObject(CM_BASE + 42));
  MsgList.AddObject ("CM_DOCWINDOWACTIVATE", TObject(CM_BASE + 43));
  MsgList.AddObject ("CM_CONTROLLISTCHANGE", TObject(CM_BASE + 44));
  MsgList.AddObject ("CM_GETDATALINK", TObject(CM_BASE + 45));
  MsgList.AddObject ("CM_CHILDKEY", TObject(CM_BASE + 46));
  MsgList.AddObject ("CM_DRAG", TObject(CM_BASE + 47));
  MsgList.AddObject ("CM_HINTSHOW", TObject(CM_BASE + 48));
  MsgList.AddObject ("CM_DIALOGHANDLE", TObject(CM_BASE + 49));
  MsgList.AddObject ("CM_ISTOOLCONTROL", TObject(CM_BASE + 50));
  MsgList.AddObject ("CM_EXECPROC", TObject($8FFF));
  MsgList.AddObject ("CM_TABFONTCHANGED", TObject(CM_BASE + 100));
  MsgList.AddObject ("CM_DEFERLAYOUT", TObject(WM_USER + 100));

  MsgList.AddObject ("CN_CHARTOITEM", TObject(CN_BASE + WM_CHARTOITEM));
  MsgList.AddObject ("CN_COMMAND", TObject(CN_BASE + WM_COMMAND));
  MsgList.AddObject ("CN_COMPAREITEM", TObject(CN_BASE + WM_COMPAREITEM));
  MsgList.AddObject ("CN_CTLCOLORBTN", TObject(CN_BASE + WM_CTLCOLORBTN));
  MsgList.AddObject ("CN_CTLCOLORDLG", TObject(CN_BASE + WM_CTLCOLORDLG));
  MsgList.AddObject ("CN_CTLCOLOREDIT", TObject(CN_BASE + WM_CTLCOLOREDIT));
  MsgList.AddObject ("CN_CTLCOLORLISTBOX", TObject(CN_BASE + WM_CTLCOLORLISTBOX));
  MsgList.AddObject ("CN_CTLCOLORMSGBOX", TObject(CN_BASE + WM_CTLCOLORMSGBOX));
  MsgList.AddObject ("CN_CTLCOLORSCROLLBAR", TObject(CN_BASE + WM_CTLCOLORSCROLLBAR));
  MsgList.AddObject ("CN_CTLCOLORSTATIC", TObject(CN_BASE + WM_CTLCOLORSTATIC));
  MsgList.AddObject ("CN_DELETEITEM", TObject(CN_BASE + WM_DELETEITEM));
  MsgList.AddObject ("CN_DRAWITEM", TObject(CN_BASE + WM_DRAWITEM));
  MsgList.AddObject ("CN_HSCROLL", TObject(CN_BASE + WM_HSCROLL));
  MsgList.AddObject ("CN_MEASUREITEM", TObject(CN_BASE + WM_MEASUREITEM));
  MsgList.AddObject ("CN_PARENTNOTIFY", TObject(CN_BASE + WM_PARENTNOTIFY));
  MsgList.AddObject ("CN_VKEYTOITEM", TObject(CN_BASE + WM_VKEYTOITEM));
  MsgList.AddObject ("CN_VSCROLL", TObject(CN_BASE + WM_VSCROLL));
  MsgList.AddObject ("CN_KEYDOWN", TObject(CN_BASE + WM_KEYDOWN));
  MsgList.AddObject ("CN_KEYUP", TObject(CN_BASE + WM_KEYUP));
  MsgList.AddObject ("CN_CHAR", TObject(CN_BASE + WM_CHAR));
  MsgList.AddObject ("CN_SYSKEYDOWN", TObject(CN_BASE + WM_SYSKEYDOWN));
  MsgList.AddObject ("CN_SYSCHAR", TObject(CN_BASE + WM_SYSCHAR));
  MsgList.AddObject ("CN_NOTIFY", TObject(CN_BASE + WM_NOTIFY));
end.


unit ViewMsg;

interface

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

type
  TForm2 = class(TForm)
    ListBox1: TListBox;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

end.


unit WndProForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    ListBox1: TListBox;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    Bevel1: TBevel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
  private
    Last: Integer;
  public
    procedure WndProc (var Message: TMessage); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  ViewMsg, MList;

procedure TForm1.WndProc (var Message: TMessage);
begin
  if not (Message.Msg = Last) then
  begin
    with Form2.Listbox1 do
      ItemIndex := Items.Add (GetMessageName (Message.Msg));
    Last := Message.Msg;
  end;
  inherited WndProc (Message);
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  Color := clBlue;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
  Color := clRed;
  end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
  Color := clLtGray;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Caption := Edit1.Text;
end;

procedure TForm1.SpeedButton5Click(Sender: TObject);
var
  Pos: Integer;
begin
  // exchange Left and Top
  Pos := (Sender as TControl).Left;
  (Sender as TControl).Left := (Sender as TControl).Top;
  (Sender as TControl).Top := Pos;
end;

end.

Загрузить исходный код проекта


Обсудить статью на форуме


Если Вас заинтересовала или понравилась информация по разработке на Delph - "Мониторинг сообщений", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу:

Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!
   


Copyright © 2008 - 2021 Дискета.info