比如这个结构就带句柄(放到了第二个参数):
TWMContextMenu = packed record Msg: Cardinal; hWnd: HWND; case Integer of 0: ( XPos: Smallint; YPos: Smallint); 1: ( Pos: TSmallPoint; Result: Longint); end;
这个也带,因为确实需要:
TWMDropFiles = packed record Msg: Cardinal; Drop: THANDLE; Unused: Longint; Result: Longint; end;
这里甚至带了2个句柄:
TWMSizeClipboard = packed record Msg: Cardinal; Viewer: HWND; RC: THandle; 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; TWMTimer = packed record Msg: Cardinal; TimerID: Longint; TimerProc: TFarProc; Result: Longint; end;
但是看了一遍Messages.pas定义的消息结构,几乎全都是16字节大小,没有找到例外,这是为什么呢?
甚至即使明明不使用那么多空间,还要加一个Unused:
TWMSystemError = packed record Msg: Cardinal; ErrSpec: Word; Unused: Longint; Result: Longint; end;
时间: 2024-12-14 00:10:06