本文介绍了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_APPRegisterWindowMessage),那么你显然有更多的自由度.

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 时代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