[英]Where are the rest of the TMessage missing params?
The VCL TMessage
class provides the Message
, WParam
and LParam
members, but a window message has more members: VCL TMessage
类提供Message
、 WParam
和LParam
成员,但一个窗口消息有更多的成员:
typedef struct tagMSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
DWORD lPrivate;
} MSG, *PMSG, *NPMSG, *LPMSG;
Where are the hwnd
, time
, pt
and lPrivate
members? hwnd
、 time
、 pt
和lPrivate
成员在哪里? I'm in specially need of the time
parameter.我特别需要time
参数。
Is there a way to access the original message that TMessage
is constructed from (or any other means to get the time
parameter)?有没有办法访问构建TMessage
的原始消息(或任何其他获取time
参数的方法)?
I'm handling my messages in TComponent::WndProc(Winapi::Messages::TMessage &Message)
.我在TComponent::WndProc(Winapi::Messages::TMessage &Message)
处理我的消息。
Where are the
hwnd
,time
,pt
andlPrivate
members?hwnd
、time
、pt
和lPrivate
成员在哪里?
There aren't any such members in TMessage
. TMessage
中没有任何此类成员。
MSG
is the structure that the Win32 API uses in a message loop to retrieve messages from a message queue , via the GetMessage()
and PeekMessage()
functions, prior to dispatching them to window procedures via DispatchMessage()
. MSG
是 Win32 API 在消息循环中使用的结构,在通过DispatchMessage()
将它们分派到窗口过程之前,通过GetMessage()
和PeekMessage()
函数从消息队列中检索消息。 The time
, pt
, and lPrivate
values are not delivered to a window procedure, however a window procedure can retrieve the time
and pt
values via the GetMessageTime()
and GetMessagePos()
functions, respectively (the lPrivate
value is not accessible). time
、 pt
和lPrivate
值不会传递给窗口过程,但是窗口过程可以分别通过GetMessageTime()
和GetMessagePos()
函数检索time
和pt
值( lPrivate
值不可访问)。
TMessage
is the structure that the VCL uses in window procedures that are created by the RTL's MakeObjectInstance()
function. TMessage
是 VCL 在由 RTL 的MakeObjectInstance()
函数创建的窗口过程中使用的结构。 This function allows classes, like the VCL's TWinControl
and TTimer
, to use non-static virtual WndProc()
methods as Win32 window procedures.此函数允许类,如 VCL 的TWinControl
和TTimer
,使用非静态虚拟WndProc()
方法作为 Win32 窗口过程。
In a standard Win32 window procedure , there are only 4 parameters available - hWnd
, uMsg
, wParam
and lParam
.在标准的 Win32 窗口过程中,只有 4 个参数可用 - hWnd
、 uMsg
、 wParam
和lParam
。 An RTL-based window procedure ignores the hWnd
(as it already knows exactly which object method to call), copies the uMsg
, wParam
and lParam
values into a TMessage
, calls the target WndProc()
method passing it the TMessage
, and then returns the TMessage::Result
value back to the OS.基于 RTL 的窗口过程忽略hWnd
(因为它已经确切知道要调用哪个对象方法),将uMsg
、 wParam
和lParam
值复制到TMessage
,调用目标WndProc()
方法传递TMessage
,然后返回TMessage::Result
值返回给操作系统。
I'm in specially need of the
time
parameter.我特别需要time
参数。 Is there a way to access the original message that TMessage is constructed from (or any other means to get the time parameter)?有没有办法访问构建 TMessage 的原始消息(或任何其他获取时间参数的方法)?
If the message comes from the message queue of the thread that is calling your WndProc()
, you can use the Win32 API GetMessageTime()
function.如果消息来自调用WndProc()
的线程的消息队列,则可以使用 Win32 API GetMessageTime()
函数。 Or, you can use the Win32 API SetWindowsHookEx()
function to install a WH_GETMESSAGE
hook into the thread's message queue.或者,您可以使用 Win32 API SetWindowsHookEx()
函数将WH_GETMESSAGE
挂钩安装到线程的消息队列中。
If your component's WndProc()
is called in the main UI thread specifically, you can alternatively use the VCL's TApplication::OnMessage
or TApplicationEvents::OnMessage
events, which receive a copy of the original MSG
structure.如果您的组件的WndProc()
专门在主 UI 线程中调用,您也可以使用 VCL 的TApplication::OnMessage
或TApplicationEvents::OnMessage
事件,它们接收原始MSG
结构的副本。 Your component can use a private TApplicationEvents
object to hook the OnMessage
event.您的组件可以使用私有的TApplicationEvents
对象来挂钩OnMessage
事件。
However, a window procedure can receive both queued messages and non-queued messages , so if the message does not come from the calling thread's message queue at all, then there is simply no time
(or pt
) value available to retrieve for it, as non-queued messages do not go through the MSG
structure to begin with.但是,窗口过程可以接收排队消息和非排队消息,因此如果消息根本不是来自调用线程的消息队列,那么根本没有time
(或pt
)值可用于检索它,如非排队消息一开始不通过MSG
结构。
I'm handling my messages in TComponent::WndProc(Winapi::Messages::TMessage &Message).我在 TComponent::WndProc(Winapi::Messages::TMessage &Message) 中处理我的消息。
TComponent
does not have a WndProc()
method. TComponent
没有WndProc()
方法。 Perhaps you are thinking of TWinControl::WndProc()
instead?也许您正在考虑TWinControl::WndProc()
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.