CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    1

    What is LRESULT? How do I use it?

    I am using a message map with a custom ON_MESSAGE handler. The callback function called by the message handler requres the return type to be LRESULT, but I am not clear on understanding what I should return in the LRSULT, and how the return value is used.

    my callback function called by the ON_MESSAGE call in the message map calls a function like:
    LRESULT ClassName::CallbackFunction(WPARAM wParam, LPARAM lParam);
    and I have found many examples online that return "LRESULT(true)" from this function, but little explanation of why return true. Could I/Should I return other values ever? What does this return value get used for?

    MSDN's explanation that LRESULT is the "Signed result of message processing." and is typdef'd from LONG_PTR doesn't give me the insight I was hoping for. Thanks for your help!

  2. #2
    Join Date
    Aug 2003
    Posts
    938

    Re: What is LRESULT? How do I use it?

    It depends on what you are trying to do, but if you are using it from ON_MESSAGE the returned values usually doesn't matter. return 0L; should do fine.

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: What is LRESULT? How do I use it?

    If you are using a custom message, then Quell's advice is OK, but if you are handing a message normally handled by the default windows proc, then you should return TRUE to indicate that you handled the message and the default proc need not bother; otherwise, the default windows proc will still process it and could override anything you already did.

  4. #4
    Join Date
    Jul 2007
    Location
    Richmond, BC
    Posts
    79

    Re: What is LRESULT? How do I use it?

    You should read what Windows expects for each message you want to handle. For some of them it expects 0, for others - something else.

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

Featured