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. The Lounge
  3. WM_APP vs WM_USER

WM_APP vs WM_USER

Scheduled Pinned Locked Moved The Lounge
5 Posts 5 Posters 0 Views
  • 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.
  • C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #1

    I'm having a discussion with Masoud Samimi about user-defined messages. In Programming Windows with MFC 2nd Ed. by Jeff Prosise, Jeff states on page 431:

    WM_USER, which is defined as 0x400 in the header file Winuser.h, specifies the low end of a range of message IDs an application can use without conflicting with the message IDs of standard Windows messages such as WM_CREATE and WM_PAINT. An application is free to use message IDs from WM_USER's 0x400 through 0x7FFF for its own purposes. Messages in this range are referred to as user-defined messages. Because dialog boxes use some message IDs in this range themselves, DlgDemo2 arbitrarily adds 0x100 to WM_USER to avoid conflicts.

    I grew up with the idea that WM_USER + n messages should be avoided becuase MFC uses message numbers close to this range, and you are never sure when MS will add new MFC messages, possibly above the WM_USER+0x100 limit. Instead, users should use values above WM_APP, or better still, use ::RegisterMessage() to ensure a unique value. What's the current thinking on this? cheers, Chris Maunde

    L M B U 4 Replies Last reply
    0
    • C Chris Maunder

      I'm having a discussion with Masoud Samimi about user-defined messages. In Programming Windows with MFC 2nd Ed. by Jeff Prosise, Jeff states on page 431:

      WM_USER, which is defined as 0x400 in the header file Winuser.h, specifies the low end of a range of message IDs an application can use without conflicting with the message IDs of standard Windows messages such as WM_CREATE and WM_PAINT. An application is free to use message IDs from WM_USER's 0x400 through 0x7FFF for its own purposes. Messages in this range are referred to as user-defined messages. Because dialog boxes use some message IDs in this range themselves, DlgDemo2 arbitrarily adds 0x100 to WM_USER to avoid conflicts.

      I grew up with the idea that WM_USER + n messages should be avoided becuase MFC uses message numbers close to this range, and you are never sure when MS will add new MFC messages, possibly above the WM_USER+0x100 limit. Instead, users should use values above WM_APP, or better still, use ::RegisterMessage() to ensure a unique value. What's the current thinking on this? cheers, Chris Maunde

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm think you're sure. I normally use WM_APP because the SDK docs say: ---- SDK docs quote start ---- Only use RegisterWindowMessage when more than one application must process the same message. For sending private messages within a window class, an application can use any integer in the range WM_USER through 0x7FFF. (Messages in this range are private to a window class, not to an application. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use values in this range.) ---- SDK docs quote end ---- Use RegisterWindowMessage with a GUID would be the most relialble solution I think but I would like to know why the sdk docs says use AM_APP for private message used only by one app.

      1 Reply Last reply
      0
      • C Chris Maunder

        I'm having a discussion with Masoud Samimi about user-defined messages. In Programming Windows with MFC 2nd Ed. by Jeff Prosise, Jeff states on page 431:

        WM_USER, which is defined as 0x400 in the header file Winuser.h, specifies the low end of a range of message IDs an application can use without conflicting with the message IDs of standard Windows messages such as WM_CREATE and WM_PAINT. An application is free to use message IDs from WM_USER's 0x400 through 0x7FFF for its own purposes. Messages in this range are referred to as user-defined messages. Because dialog boxes use some message IDs in this range themselves, DlgDemo2 arbitrarily adds 0x100 to WM_USER to avoid conflicts.

        I grew up with the idea that WM_USER + n messages should be avoided becuase MFC uses message numbers close to this range, and you are never sure when MS will add new MFC messages, possibly above the WM_USER+0x100 limit. Instead, users should use values above WM_APP, or better still, use ::RegisterMessage() to ensure a unique value. What's the current thinking on this? cheers, Chris Maunde

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        I always use WM_APP, since many (most?) of the common control messages are defined as WM_USER+n, and using WM_APP for my own messages avoids any collisions

        1 Reply Last reply
        0
        • C Chris Maunder

          I'm having a discussion with Masoud Samimi about user-defined messages. In Programming Windows with MFC 2nd Ed. by Jeff Prosise, Jeff states on page 431:

          WM_USER, which is defined as 0x400 in the header file Winuser.h, specifies the low end of a range of message IDs an application can use without conflicting with the message IDs of standard Windows messages such as WM_CREATE and WM_PAINT. An application is free to use message IDs from WM_USER's 0x400 through 0x7FFF for its own purposes. Messages in this range are referred to as user-defined messages. Because dialog boxes use some message IDs in this range themselves, DlgDemo2 arbitrarily adds 0x100 to WM_USER to avoid conflicts.

          I grew up with the idea that WM_USER + n messages should be avoided becuase MFC uses message numbers close to this range, and you are never sure when MS will add new MFC messages, possibly above the WM_USER+0x100 limit. Instead, users should use values above WM_APP, or better still, use ::RegisterMessage() to ensure a unique value. What's the current thinking on this? cheers, Chris Maunde

          B Offline
          B Offline
          Byron Thomas Cullen
          wrote on last edited by
          #4

          I really liked Joseph M. Newcomer's article "Message Management" and since then I have been using registered messages. It's only slightly more work but it seems to give me a little more assurance than WM_APP+ or WM_USER+ I have to admit that I have not, in recent memory, experienced any sort of message collision/confusion with WM_APP+ but I don't really use than many user-defined messages in my apps. Mr. Mewcomer seemed to have some solid reasons to his methods and I can't think of a good reason not to follow his lead :) so that's my answer. Does anyone know if there is a limit to the number of UDM's you can register? Byro

          1 Reply Last reply
          0
          • C Chris Maunder

            I'm having a discussion with Masoud Samimi about user-defined messages. In Programming Windows with MFC 2nd Ed. by Jeff Prosise, Jeff states on page 431:

            WM_USER, which is defined as 0x400 in the header file Winuser.h, specifies the low end of a range of message IDs an application can use without conflicting with the message IDs of standard Windows messages such as WM_CREATE and WM_PAINT. An application is free to use message IDs from WM_USER's 0x400 through 0x7FFF for its own purposes. Messages in this range are referred to as user-defined messages. Because dialog boxes use some message IDs in this range themselves, DlgDemo2 arbitrarily adds 0x100 to WM_USER to avoid conflicts.

            I grew up with the idea that WM_USER + n messages should be avoided becuase MFC uses message numbers close to this range, and you are never sure when MS will add new MFC messages, possibly above the WM_USER+0x100 limit. Instead, users should use values above WM_APP, or better still, use ::RegisterMessage() to ensure a unique value. What's the current thinking on this? cheers, Chris Maunde

            U Offline
            U Offline
            User 3819
            wrote on last edited by
            #5

            I'm using 0x7FFF - n to be sure that there are no problem with extra libraries that I us

            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

            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups