Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WPARAM and LPARAM ?

WPARAM and LPARAM ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Owner drawn
    wrote on last edited by
    #1

    This may sound silly. Is there any specific guideline as to what goes into WPARAM and LPARAM or does it depend on the event that uses it. I sometimes get confused with this. :confused:. And of course both are 32 bit.

    Jesus Loves:rose:

    --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

    P C O B 4 Replies Last reply
    0
    • O Owner drawn

      This may sound silly. Is there any specific guideline as to what goes into WPARAM and LPARAM or does it depend on the event that uses it. I sometimes get confused with this. :confused:. And of course both are 32 bit.

      Jesus Loves:rose:

      --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      in the header file it says, /* Types use for passing & returning polymorphic values */ typedef UINT WPARAM; typedef LONG LPARAM; typedef LONG LRESULT; so WPARAM can be anything as long as you dont want to pass a negative values, LPARAM can take negative values, Also both are used for polymorphic values, so anything from number of trees to pointers can go there ;) I generally use LPARAM for pointers only.


      -Prakash

      1 Reply Last reply
      0
      • O Owner drawn

        This may sound silly. Is there any specific guideline as to what goes into WPARAM and LPARAM or does it depend on the event that uses it. I sometimes get confused with this. :confused:. And of course both are 32 bit.

        Jesus Loves:rose:

        --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        The guideline is indeed tied to the event. That's the point, a generate purpose param that can hold whatever the event wants to pass. Christian Graus - Microsoft MVP - C++

        1 Reply Last reply
        0
        • O Owner drawn

          This may sound silly. Is there any specific guideline as to what goes into WPARAM and LPARAM or does it depend on the event that uses it. I sometimes get confused with this. :confused:. And of course both are 32 bit.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          In LPARAM or in WPARAM.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

          P 1 Reply Last reply
          0
          • O Owner drawn

            In LPARAM or in WPARAM.

            Jesus Loves:rose:

            --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

            P Offline
            P Offline
            Prakash Nadar
            wrote on last edited by
            #5

            HWND is a handle, so you dont know what value it would hold, so i would put that on LPARAM.


            -Prakash

            1 Reply Last reply
            0
            • O Owner drawn

              This may sound silly. Is there any specific guideline as to what goes into WPARAM and LPARAM or does it depend on the event that uses it. I sometimes get confused with this. :confused:. And of course both are 32 bit.

              Jesus Loves:rose:

              --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #6

              I am not sure if this still hold true, maybe someone else knows, but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters. Therefore, I am careful, still, to only pass 16-bit or less values in WPARAM. LPARAM never had any such issues.

              O 1 Reply Last reply
              0
              • B Blake Miller

                I am not sure if this still hold true, maybe someone else knows, but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters. Therefore, I am careful, still, to only pass 16-bit or less values in WPARAM. LPARAM never had any such issues.

                O Offline
                O Offline
                Owner drawn
                wrote on last edited by
                #7

                Blake Miller wrote:

                but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters

                Can you suggest message filters. I would like to know. So in your opinion what should I do for consistency sake. A few guidelines from you would be helpful. Or maybe what do you do normally.

                Jesus Loves:rose:

                --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                B 1 Reply Last reply
                0
                • O Owner drawn

                  Blake Miller wrote:

                  but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters

                  Can you suggest message filters. I would like to know. So in your opinion what should I do for consistency sake. A few guidelines from you would be helpful. Or maybe what do you do normally.

                  Jesus Loves:rose:

                  --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                  B Offline
                  B Offline
                  Blake Miller
                  wrote on last edited by
                  #8

                  I am not sure which message filters would truncate WPARAM to 16 bits. However, that is WHY it was originally called WPARAM - because it was limited to being a WORD (16-bits). I limit WPARAM in my work to 16 bits. I use LPARAM full 32 bits. Usually I do not try to pass pointers or much data through the messages. I pass messages as notifications only between 'subsystems' and rely upon data retrieval function calls to be made to collect the data itself. Some programmers rely upon SendMessage to pass pointers to data via the message queue between subsystems, but that ends up being more trouble to synchyronize with the sending and receiving windows' other activities and other events occuring in a multithreaded envionment. Sure I guess it works okay if the application has a signle thread, but that is not the type of code I am typically writing anyway.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups