Results 1 to 3 of 3

Thread: How do I use SendMessage and GetMessage?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    How do I use SendMessage and GetMessage?

    I want to be able to send data from one program to another with SendMessage and GetMessage (in the user message range from &h0400 to &h7fff). The problem is on the receiving end, GetMessage "blocks" so that the program locks up whenever it is not receiving a message. And the problem with the alternative PeekMessage (which isn't a "blocking" function) is it doesn't catch every message sent (so it might miss a very important piece of data if the one it missed was this important piece of data). Please help here. Thanks in advance.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,422

    Re: How do I use SendMessage and GetMessage?

    I'd rather subclass the windows-procedure on the receiving end with a unique message-header sent by the sender (e.g. WM_Custom or something) with the pertinent data sent in lparam or wparam.
    In that way it's a simple Select Case on the receiving end.

    Everything with WM_Custom (or whatever) as a message: Do your stuff
    Everything else: delegate to the original windows-procedure
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How do I use SendMessage and GetMessage?

    Also note that:

    Message numbers in the first range (0 through WM_USER–1) are defined by the system. Values in this range that are not explicitly defined are reserved by the system.

    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 (0x8000 through 0xBFFF) are available for applications to use as private messages. Messages in this range do not conflict with system messages.
    WM_USER through 0x7FFF is not a safe range for the purpose you've described.

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