0

I know that wParam and lParam are (32 bit I belive) bits of information specific to the message being passed at the time, but is there any way to tell what each message puts into the two?

I read somewhere that wParam is 16 bit and lParam is 32 bit, but it still doesn't really explain what I should expect to see, or at least which variable I should expect to see something in. I've seen some examples of messages using lParam, and other examples of messages using wParam, and yet other examples of both being used.

For instance, I saw keydown uses wParam for receiving a specific key, but lParam is used in LButtondown, with the upper 16 being the y, and the lower 16 being the x. The reason that one specifically should be in lParam makes sense (because it takes 32 bits), but how can I find out which one other messages send, and what is in them?

(sorry, I think I may have repeated my question a couple times in that slight rant)

David Torrey
  • 1,335
  • 3
  • 20
  • 43
  • A related question: [What are the definitions for LPARAM and WPARAM?](http://stackoverflow.com/questions/2515261/what-are-the-definitions-for-lparam-and-wparam?rq=1) – Bo Persson Aug 07 '12 at 10:52

3 Answers3

5

I'm sorry. But the reliable way to know what is being passed in the wParam and lParam of each message is to refer to the documentation.

I read somewhere that wParam is 16 bit and lParam is 32 bit

According to this, WPARAM is an unsigned (32-bit) int, while LPARAM is a signed long.

ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
  • so basically there isn't a specific rhyme or reason one is used over the other, i just have to rely on the documentation to figure each message out? I mean, I guess that makes sense, I guess I just wanted to know if there was a pattern. thanks! – David Torrey Aug 07 '12 at 10:39
  • @DavidTorrey Yeah. It's pretty troublesome at first, but over time you get used to and pretty much memorize the values of most of the common messages. – ApprenticeHacker Aug 07 '12 at 10:44
  • 2
    @DavidTorrey: Back in the old days, WPARAM was 16 bits but LPARAM has always been 32 bits. Because of this, generally speaking, LPARAM is used for pointers and WPARAM is used for integral values. But really you should read the documentation. – john Aug 07 '12 at 10:51
  • 1
    Also, note that these are currently "pointer sized": so on Win32, they are 32 bits, but when code is compiled as Win64, they are 64 bits (similarly for LRESULT). – BrendanMcK Aug 17 '12 at 22:16
3

You have to look at the MSDN reference for each message you are interested in and individually read what significance wParam and lParam have for it. A full reference can be found here.

Jon
  • 428,835
  • 81
  • 738
  • 806
1

just take a look at the documentation of microsoft: as example WM_KEYDOWN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280(v=vs.85).aspx

Florian
  • 5,918
  • 3
  • 47
  • 86