本文介绍了WPARAM和LPARAM参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将值传递给同时带有WPARAM和LPARAM参数的函数时,我在哪一个参数上传递都无关紧要?有人告诉我,如果使用Windows x64,则应使用WPARAM;这是真的?

When passing a value to a function that takes both a WPARAM and a LPARAM parameter, does it matter on which of them I pass it? Someone told me that if I use Windows x64 I should use WPARAM; is this true?

推荐答案

发送消息时,根据消息,WPARAMLPARAM参数具有特定的解释.您需要以要发送的消息期望它们通过的方式传递这些参数.如果您要定义自己的消息(例如,通过与 WM_USER WM_APP RegisterWindowMessage ),那么您显然拥有更多的自由度.

When sending messages, WPARAM and LPARAM parameters have specific interpretations depending on the message. You need to pass those parameters in the way that the message that you are sending expects them to be passed. If you are defining your own message (perhaps via an offset from WM_USER, WM_APP, or RegisterWindowMessage), then you obviously have a bit more latitude.

在16位Windows时代 a>,WPARAM是16位字,而LPARAM是32位长.这些区别在Win32中消失了.它们都变成了32位值.

In the days of 16-bit Windows, a WPARAM was a 16-bit word, while LPARAM was a 32-bit long. These distinctions went away in Win32; they both became 32-bit values.

根据LPARAM定义为LONG_PTR,在64位Windows中,它是一个带符号的64位值. WPARAM定义为UINT_PTR,在64位Windows中,它是一个无符号的64位值.如果要定义自己的消息,则可能需要相应地分配其参数.

According to this, LPARAM is defined as LONG_PTR, which in 64-bit Windows is a signed, 64-bit value. WPARAM is defined as UINT_PTR, which in 64-bit Windows is an unsigned, 64-bit value. If you are defining your own message, you might want to assign its parameters accordingly.

这篇关于WPARAM和LPARAM参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:59