Results 1 to 5 of 5

Thread: Creating Windows Messages

  1. #1
    Guest
    Hi,

    I have two components which share a common class, and I want to use SendMessage to allow this class the communicate with the components.

    How would I go about creating a message which I know is not being used by the system. For example, is there a limit on the default messages (a bit like the vbObjectError constant). Or can Windows itself assign me a free message id?

    Thanks;

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Extracted from MSDN Library:
    Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class. These values cannot be used to define messages that are meaningful throughout an application, because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. Messages in this range should not be sent to other applications unless the applications have been designed to exchange messages and to attach the same meaning to the message numbers.

    Message numbers in the third range (WM_APP through 0xBFFF) are available for application to use as private messages. Message in this range do not conflict with system messages.
    I would go with WM_APP + n instead of WM_USER + n.
    The WM_APP constant has the value &H8000.
    You can also use the RegisterWindowMessage API function to get a message that is guaranteed to be unique throughout the system.

  3. #3
    Guest

    Another solution to a not-so-easy question! I'm impressed!

    I have just tested using the RegisterWindowMessage function, and this works fine.

    Thanks!

  4. #4
    Guest

    WM_APP?

    Joacim,

    Here's an interesting problem under Windows 2000:

    If I send a message to my window using a message defined via WM_APP + xxx, the message does not arrive.

    However, if I send a message created using the RegisterWindowMessage API, everything works fine.

    The WM_APP messages work fine on Windows 98.

    Does NT not like negative messages or something?

    Strange!

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You should store the message in a Long and not an Integer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width