• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi7里Messages.pas里所有104种重定义消息种类,180种不同的消息名称RegisterWindo ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

 

Delphi 7里Messages.pas里所有消息。经统计,共104种重定义消息种类,方便使用,180种不同的消息名称。省得像VC里一样,处处自己解析wParam和LParam参数进行分析。有空我要把它们一个一个标注和学习一下。另外要强调一点:Delphi里所有的消息都没有包含Handle,Handle本身不是消息的一部分(VC里也是这样),除非有些消息要用到2个Handle。但是注意,另有TMsg结构,定义在windows.pas文件里。除此之外,还定义有 TEventMsg TCreateStruct 等许多结构,都是需要学习和注意的地方。

tagMSG = packed record
hwnd: HWND;
message: UINT;
wParam: WPARAM;
lParam: LPARAM;
time: DWORD;
pt: TPoint;
end;
TMsg = tagMSG;

 

// ====================正文开始======================================

PMessage = ^TMessage;
TMessage = packed record
Msg: Cardinal; // 无论什么消息,第一个成员都是消息编号(消息字符串名称所对应的编号)
case Integer of
0: (
WParam: Longint;
LParam: Longint;
Result: Longint); // 返回值
1: (
WParamLo: Word;
WParamHi: Word;
LParamLo: Word;
LParamHi: Word;
ResultLo: Word;  // 返回值
ResultHi: Word);
end;

{ Common message format records }

// 无论消息怎么重定义,总长度都是4个integer

TWMNoParams = packed record
Msg: Cardinal;
Unused: array[0..3] of Word;
Result: Longint;
end;

TWMKey = packed record // 按键
Msg: Cardinal;
CharCode: Word;
Unused: Word;
KeyData: Longint;
Result: Longint;
end;

TWMMouse = packed record // 鼠标
Msg: Cardinal;
Keys: Longint;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TWMMouseWheel = packed record // 鼠标滚轮
Msg: Cardinal;
Keys: SmallInt;
WheelDelta: SmallInt;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TMSHMouseWheel = packed record // MS鼠标滚轮
Msg: Cardinal;
WheelDelta: Integer;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TWMWindowPosMsg = packed record // 窗口位置
Msg: Cardinal;
Unused: Integer;
WindowPos: PWindowPos;
Result: Longint;
end;

TWMScroll = packed record // 滚动条消息
Msg: Cardinal;
ScrollCode: Smallint; { SB_xxxx }
Pos: Smallint;
ScrollBar: HWND;
Result: Longint;
end;

{ Message records }

TWMActivate = packed record
Msg: Cardinal;
Active: Word; { WA_INACTIVE, WA_ACTIVE, WA_CLICKACTIVE }
Minimized: WordBool;
ActiveWindow: HWND;
Result: Longint;
end;

TWMActivateApp = packed record
Msg: Cardinal;
Active: BOOL;
ThreadId: Longint;
Result: Longint;
end;

TWMAskCBFormatName = packed record
Msg: Cardinal;
NameLen: Word;
Unused: Word;
FormatName: PChar;
Result: Longint;
end;

TWMCancelMode = TWMNoParams;

TWMChangeCBChain = packed record // 难道是Hook消息?
Msg: Cardinal;
Remove: HWND;
Next: HWND;
Result: Longint;
end;

TWMChar = TWMKey;

TWMCharToItem = packed record
Msg: Cardinal;
Key: Word;
CaretPos: Word;
ListBox: HWND;
Result: Longint;
end;

TWMChildActivate = TWMNoParams;

TWMChooseFont_GetLogFont = packed record
Msg: Cardinal;
Unused: Longint;
LogFont: PLogFont;
Result: Longint;
end;

TWMClear = TWMNoParams;
TWMClose = TWMNoParams;

TWMCommand = packed record
Msg: Cardinal;
ItemID: Word;
NotifyCode: Word;
Ctl: HWND;
Result: Longint;
end;

TWMCompacting = packed record
Msg: Cardinal;
CompactRatio: Longint;
Unused: Longint;
Result: Longint;
end;

TWMCompareItem = packed record
Msg: Cardinal;
Ctl: HWnd;
CompareItemStruct: PCompareItemStruct;
Result: Longint;
end;

TWMCopy = TWMNoParams;

TWMCopyData = packed record
Msg: Cardinal;
From: HWND;
CopyDataStruct: PCopyDataStruct;
Result: Longint;
end;

{ ?? WM_CLP_LAUNCH, WM_CPL_LAUNCHED }

TWMCreate = packed record
Msg: Cardinal;
Unused: Integer;
CreateStruct: PCreateStruct;
Result: Longint;
end;

TWMCtlColor = packed record
Msg: Cardinal;
ChildDC: HDC;
ChildWnd: HWND;
Result: Longint;
end;

TWMCtlColorBtn = TWMCtlColor;
TWMCtlColorDlg = TWMCtlColor;
TWMCtlColorEdit = TWMCtlColor;
TWMCtlColorListbox = TWMCtlColor;
TWMCtlColorMsgbox = TWMCtlColor;
TWMCtlColorScrollbar = TWMCtlColor;
TWMCtlColorStatic = TWMCtlColor;

TWMCut = TWMNoParams;

TWMDDE_Ack = packed record
Msg: Cardinal;
PostingApp: HWND;
case Word of
WM_DDE_INITIATE: (
App: Word;
Topic: Word;
Result: Longint);
WM_DDE_EXECUTE {and all others}: (
PackedVal: Longint);
end;

TWMDDE_Advise = packed record
Msg: Cardinal;
PostingApp: HWND;
PackedVal: Longint;
Result: Longint;
end;

TWMDDE_Data = packed record
Msg: Cardinal;
PostingApp: HWND;
PackedVal: Longint;
Result: Longint;
end;

TWMDDE_Execute = packed record
Msg: Cardinal;
PostingApp: HWND;
Commands: THandle;
Result: Longint;
end;

TWMDDE_Initiate = packed record
Msg: Cardinal;
PostingApp: HWND;
App: Word;
Topic: Word;
Result: Longint;
end;

TWMDDE_Poke = packed record
Msg: Cardinal;
PostingApp: HWND;
PackedVal: Longint;
Result: Longint;
end;

TWMDDE_Request = packed record
Msg: Cardinal;
PostingApp: HWND;
Format: Word;
Item: Word;
Result: Longint;
end;

TWMDDE_Terminate = packed record
Msg: Cardinal;
PostingApp: HWND;
Unused: Longint;
Result: Longint;
end;

TWMDDE_Unadvise = packed record
Msg: Cardinal;
PostingApp: HWND;
Format: Word;
Item: Word;
Result: Longint;
end;

TWMDeadChar = TWMChar;

TWMDeleteItem = packed record
Msg: Cardinal;
Ctl: HWND;
DeleteItemStruct: PDeleteItemStruct;
Result: Longint;
end;

TWMDestroy = TWMNoParams;
TWMDestroyClipboard = TWMNoParams;

TWMDevModeChange = packed record
Msg: Cardinal;
Unused: Integer;
Device: PChar;
Result: Longint;
end;

TWMDrawClipboard = TWMNoParams;

TWMDrawItem = packed record
Msg: Cardinal;
Ctl: HWND;
DrawItemStruct: PDrawItemStruct;
Result: Longint;
end;

TWMDropFiles = packed record
Msg: Cardinal;
Drop: THANDLE;
Unused: Longint;
Result: Longint;
end;

TWMEnable = packed record
Msg: Cardinal;
Enabled: LongBool;
Unused: Longint;
Result: Longint;
end;

TWMEndSession = packed record
Msg: Cardinal;
EndSession: LongBool;
Unused: Longint;
Result: Longint;
end;

TWMEnterIdle = packed record
Msg: Cardinal;
Source: Longint; { MSGF_DIALOGBOX, MSGF_MENU }
IdleWnd: HWND;
Result: Longint;
end;

TWMEnterMenuLoop = packed record
Msg: Cardinal;
IsTrackPopupMenu: LongBool;
Unused: Longint;
Result: Longint;
end;

TWMExitMenuLoop = TWMEnterMenuLoop;

TWMEraseBkgnd = packed record // 擦除背景
Msg: Cardinal;
DC: HDC; // 已经含有DC句柄了
Unused: Longint;
Result: Longint;
end;

TWMFontChange = TWMNoParams;
TWMGetDlgCode = TWMNoParams;
TWMGetFont = TWMNoParams;

TWMGetIcon = packed record
Msg: Cardinal;
BigIcon: Longbool;
Unused: Longint;
Result: Longint;
end;

TWMGetHotKey = TWMNoParams;

TWMGetMinMaxInfo = packed record
Msg: Cardinal;
Unused: Integer;
MinMaxInfo: PMinMaxInfo;
Result: Longint;
end;

TWMGetText = packed record
Msg: Cardinal;
TextMax: Integer;
Text: PChar;
Result: Longint;
end;

TWMGetTextLength = TWMNoParams;

TWMHotKey = packed record
Msg: Cardinal;
HotKey: Longint;
Unused: Longint;
Result: Longint;
end;

TWMHScroll = TWMScroll;

TWMHScrollClipboard = packed record
Msg: Cardinal;
Viewer: HWND;
ScrollCode: Word; {SB_BOTTOM, SB_ENDSCROLL, SB_LINEDOWN, SB_LINEUP,
SB_PAGEDOWN, SB_PAGEUP, SB_THUMBPOSITION,
SB_THUMBTRACK, SB_TOP }
Pos: Word;
Result: Longint;
end;

TWMIconEraseBkgnd = TWMEraseBkgnd;

TWMInitDialog = packed record
Msg: Cardinal;
Focus: HWND;
InitParam: Longint;
Result: Longint;
end;

TWMInitMenu = packed record
Msg: Cardinal;
Menu: HMENU;
Unused: Longint;
Result: Longint;
end;

TWMInitMenuPopup = packed record
Msg: Cardinal;
MenuPopup: HMENU;
Pos: Smallint;
SystemMenu: WordBool;
Result: Longint;
end;

TWMKeyDown = TWMKey;
TWMKeyUp = TWMKey;

TWMKillFocus = packed record
Msg: Cardinal;
FocusedWnd: HWND;
Unused: Longint;
Result: Longint;
end;

TWMLButtonDblClk = TWMMouse;
TWMLButtonDown = TWMMouse;
TWMLButtonUp = TWMMouse;
TWMMButtonDblClk = TWMMouse;
TWMMButtonDown = TWMMouse;
TWMMButtonUp = TWMMouse;

TWMMDIActivate = packed record
Msg: Cardinal;
case Integer of
0: (
ChildWnd: HWND);
1: (
DeactiveWnd: HWND;
ActiveWnd: HWND;
Result: Longint);
end;

TWMMDICascade = packed record
Msg: Cardinal;
Cascade: Longint; { 0, MDITILE_SKIPDISABLED }
Unused: Longint;
Result: Longint;
end;

TWMMDICreate = packed record
Msg: Cardinal;
Unused: Integer;
MDICreateStruct: PMDICreateStruct;
Result: Longint;
end;

TWMMDIDestroy = packed record
Msg: Cardinal;
Child: HWND;
Unused: Longint;
Result: Longint;
end;

TWMMDIGetActive = TWMNoParams;
TWMMDIIconArrange = TWMNoParams;

TWMMDIMaximize = packed record
Msg: Cardinal;
Maximize: HWND;
Unused: Longint;
Result: Longint;
end;

TWMMDINext = packed record
Msg: Cardinal;
Child: HWND;
Next: Longint;
Result: Longint;
end;

TWMMDIRefreshMenu = TWMNoParams;

TWMMDIRestore = packed record
Msg: Cardinal;
IDChild: HWND;
Unused: Longint;
Result: Longint;
end;

TWMMDISetMenu = packed record
Msg: Cardinal;
MenuFrame: HMENU;
MenuWindow: HMENU;
Result: Longint;
end;

TWMMDITile = packed record
Msg: Cardinal;
Tile: Longint; { MDITILE_HORIZONTAL, MDITILE_SKIPDISABLE,
MDITILE_VERTICAL }
Unused: Longint;
Result: Longint;
end;

TWMMeasureItem = packed record
Msg: Cardinal;
IDCtl: HWnd;
MeasureItemStruct: PMeasureItemStruct;
Result: Longint;
end;

TWMMenuChar = packed record
Msg: Cardinal;
User: Char;
Unused: Byte;
MenuFlag: Word; { MF_POPUP, MF_SYSMENU }
Menu: HMENU;
Result: Longint;
end;

TWMMenuSelect = packed record
Msg: Cardinal;
IDItem: Word;
MenuFlag: Word; { MF_BITMAP, MF_CHECKED, MF_DISABLED, MF_GRAYED,
MF_MOUSESELECT, MF_OWNERDRAW, MF_POPUP, MF_SEPARATOR,
MF_SYSMENU }
Menu: HMENU;
Result: Longint;
end;

TWMMouseActivate = packed record
Msg: Cardinal;
TopLevel: HWND;
HitTestCode: Word;
MouseMsg: Word;
Result: Longint;
end;

TWMMouseMove = TWMMouse;

TWMMove = packed record
Msg: Cardinal;
Unused: Integer;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TWMMoving = packed record
Msg: Cardinal;
Edge: Integer;
DragRect: PRect;
end;

TWMNCActivate = packed record
Msg: Cardinal;
Active: BOOL;
Unused: Longint;
Result: Longint;
end;

TWMNCCalcSize = packed record
Msg: Cardinal;
CalcValidRects: BOOL;
CalcSize_Params: PNCCalcSizeParams;
Result: Longint;
end;

TWMNCCreate = packed record
Msg: Cardinal;
Unused: Integer;
CreateStruct: PCreateStruct;
Result: Longint;
end;

TWMNCDestroy = TWMNoParams;

TWMNCHitTest = packed record
Msg: Cardinal;
Unused: Longint;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TWMNCHitMessage = packed record
Msg: Cardinal;
HitTest: Longint;
XCursor: Smallint;
YCursor: Smallint;
Result: Longint;
end;

TWMNCLButtonDblClk = TWMNCHitMessage;
TWMNCLButtonDown = TWMNCHitMessage;
TWMNCLButtonUp = TWMNCHitMessage;
TWMNCMButtonDblClk = TWMNCHitMessage;
TWMNCMButtonDown = TWMNCHitMessage;
TWMNCMButtonUp = TWMNCHitMessage;
TWMNCMouseMove = TWMNCHitMessage;

TWMNCPaint = packed record
Msg: Cardinal;
RGN: HRGN;
Unused: Longint;
Result: Longint;
end;

TWMNCRButtonDblClk = TWMNCHitMessage;
TWMNCRButtonDown = TWMNCHitMessage;
TWMNCRButtonUp = TWMNCHitMessage;

TWMNextDlgCtl = packed record
Msg: Cardinal;
CtlFocus: Longint;
Handle: WordBool;
Unused: Word;
Result: Longint;
end;

TWMNotify = packed record
Msg: Cardinal;
IDCtrl: Longint;
NMHdr: PNMHdr;
Result: Longint;
end;

TWMNotifyFormat = packed record
Msg: Cardinal;
From: HWND;
Command: Longint;
Result: Longint;
end;

TWMPaint = packed record
Msg: Cardinal;
DC: HDC;
Unused: Longint;
Result: Longint;
end;

TWMPaintClipboard = packed record
Msg: Cardinal;
Viewer: HWND;
PaintStruct: THandle;
Result: Longint;
end;

TWMPaintIcon = TWMNoParams;

TWMPaletteChanged = packed record
Msg: Cardinal;
PalChg: HWND;
Unused: Longint;
Result: Longint;
end;

TWMPaletteIsChanging = packed record
Msg: Cardinal;
Realize: HWND;
Unused: Longint;
Result: Longint;
end;

TWMParentNotify = packed record
Msg: Cardinal;
case Event: Word of
WM_CREATE, WM_DESTROY: (
ChildID: Word;
ChildWnd: HWnd);
WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN: (
Value: Word;
XPos: Smallint;
YPos: Smallint);
0: (
Value1: Word;
Value2: Longint;
Result: Longint);
end;

TWMPaste = TWMNoParams;

TWMPower = packed record
Msg: Cardinal;
PowerEvt: Longint; { PWR_SUSPENDREQUEST, PWR_SUSPENDRESUME,
PWR_CRITICALRESUME }
Unused: Longint;
Result: Longint;
end;

TWMQueryDragIcon = TWMNoParams;

TWMQueryEndSession = packed record
Msg: Cardinal;
Source: Longint;
Unused: Longint;
Result: Longint;
end;

TWMQueryNewPalette = TWMNoParams;
TWMQueryOpen = TWMNoParams;
TWMQueueSync = TWMNoParams;

TWMQuit = packed record
Msg: Cardinal;
ExitCode: Longint;
Unused: Longint;
Result: Longint;
end;

TWMRButtonDblClk = TWMMouse;
TWMRButtonDown = TWMMouse;
TWMRButtonUp = TWMMouse;

TWMRenderAllFormats = TWMNoParams;

TWMRenderFormat = packed record
Msg: Cardinal;
Format: Longint;
Unused: Longint;
Result: Longint;
end;

TWMSetCursor = packed record
Msg: Cardinal;
CursorWnd: HWND;
HitTest: Word;
MouseMsg: Word;
Result: Longint;
end;

TWMSetFocus = packed record
Msg: Cardinal;
FocusedWnd: HWND;
Unused: Longint;
Result: Longint;
end;

TWMSetFont = packed record
Msg: Cardinal;
Font: HFONT;
Redraw: WordBool;
Unused: Word;
Result: Longint;
end;

TWMSetHotKey = packed record
Msg: Cardinal;
Key: Longint;
Unused: Longint;
Result: Longint;
end;

TWMSetIcon = packed record
Msg: Cardinal;
BigIcon: Longbool;
Icon: HICON;
Result: Longint;
end;

TWMSetRedraw = packed record
Msg: Cardinal;
Redraw: Longint;
Unused: Longint;
Result: Longint;
end;

TWMSetText = packed record
Msg: Cardinal;
Unused: Longint;
Text: PChar;
Result: Longint;
end;

TWMShowWindow = packed record
Msg: Cardinal;
Show: BOOL;
Status: Longint;
Result: Longint;
end;

TWMSize = packed record
Msg: Cardinal;
SizeType: Longint; { SIZE_MAXIMIZED, SIZE_MINIMIZED, SIZE_RESTORED,
SIZE_MAXHIDE, SIZE_MAXSHOW }
Width: Word;
Height: Word;
Result: Longint;
end;

TWMSizeClipboard = packed record
Msg: Cardinal;
Viewer: HWND;
RC: THandle;
Result: Longint;
end;

TWMSpoolerStatus = packed record
Msg: Cardinal;
JobStatus: Longint;
JobsLeft: Word;
Unused: Word;
Result: Longint;
end;

TWMStyleChange = packed record
Msg: Cardinal;
StyleType: Longint;
StyleStruct: PStyleStruct;
Result: Longint;
end;

TWMStyleChanged = TWMStyleChange;
TWMStyleChanging = TWMStyleChange;

TWMSysChar = TWMKey;
TWMSysColorChange = TWMNoParams;

TWMSysCommand = packed record
Msg: Cardinal;
case CmdType: Longint of
SC_HOTKEY: (ActivateWnd: HWND);
SC_KEYMENU: (Key: Word);
// 13种系统消息,另外热键和菜单消息
SC_CLOSE, SC_HSCROLL, SC_MAXIMIZE, SC_MINIMIZE, SC_MOUSEMENU, SC_MOVE,
SC_NEXTWINDOW, SC_PREVWINDOW, SC_RESTORE, SC_SCREENSAVE, SC_SIZE,
SC_TASKLIST, SC_VSCROLL: (
XPos: Smallint;
YPos: Smallint;
Result: Longint);
end;

TWMSysDeadChar = packed record
Msg: Cardinal;
CharCode: Word;
Unused: Word;
KeyData: Longint;
Result: Longint;
end;

TWMSysKeyDown = TWMKey;
TWMSysKeyUp = TWMKey;

TWMSystemError = packed record
Msg: Cardinal;
ErrSpec: Word;
Unused: Longint;
Result: Longint;
end;

TWMTimeChange = TWMNoParams;

TWMTimer = packed record
Msg: Cardinal;
TimerID: Longint;
TimerProc: TFarProc;
Result: Longint;
end;

TWMUIState = packed record
Msg: Cardinal;
Action: Word;
Flags: Word;
Unused: Longint;
end;

TWMChangeUIState = TWMUIState;
TWMUpdateUIState = TWMUIState;
TWMQueryUIState = TWMNoParams;

TWMUndo = TWMNoParams;

TWMVKeyToItem = TWMCharToItem;

TWMVScroll = TWMScroll;

TWMVScrollClipboard = packed record
Msg: Cardinal;
Viewer: HWND;
ScollCode: Word;
ThumbPos: Word;
Result: Longint;
end;

TWMWindowPosChanged = TWMWindowPosMsg;
TWMWindowPosChanging = TWMWindowPosMsg;

TWMWinIniChange = packed record
Msg: Cardinal;
Unused: Integer;
Section: PChar;
Result: Longint;
end;

TWMSettingChange = packed record
Msg: Cardinal;
Flag: Integer;
Section: PChar;
Result: Longint;
end;

TWMHelp = packed record
Msg: Cardinal;
Unused: Integer;
HelpInfo: PHelpInfo;
Result: Longint;
end;

TWMDisplayChange = packed record
Msg: Cardinal;
BitsPerPixel: Integer;
Width: Word;
Height: Word;
Result: Longint;
end;

TWMContextMenu = packed record
Msg: Cardinal;
hWnd: HWND;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;

TWMPrint = packed record
Msg: Cardinal;
DC: HDC;
Flags: Cardinal;
Result: Integer;
end;

TWMPrintClient = TWMPrint;

-----------------------------------------------------------------------------------------------------

 

RegisterWindowMessage用于在windows系统中注册一个唯一的消息。

如果注册成功时,直接返回消息号,消息号的范围在 0xC000 (3072) 到 0xFFFF (65535) 之间。

如果注册失败时,则该函数返回 0。

 

注意:当以字符串所标识的消息存在时,则直接返回该字符串所对应的消息号。

RegisterWindowMessage用于在windows系统中注册一个唯一的消息。

如果注册成功时,直接返回消息号,消息号的范围在 0xC000 (3072) 到 0xFFFF (65535) 之间。

如果注册失败时,则该函数返回 0。

 

注意:当以字符串所标识的消息存在时,则直接返回该字符串所对应的消息号。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap