|
-
June 4th, 2008, 12:07 PM
#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!
-
June 4th, 2008, 12:16 PM
#2
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.
-
June 4th, 2008, 12:40 PM
#3
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.
-
June 4th, 2008, 12:46 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|