4

Given a notification handler

BOOL CMyWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
   .......

If I process a particular notification. Should I return TRUE or set *pResult = TRUE?

This is something that's bugged me for ages.

Joseph King
  • 5,089
  • 1
  • 30
  • 37

1 Answers1

7

They are quite different things:

  • The return value, the BOOL indicates whether or not you processed the message. Non-zero if you processed it, zero otherwise. This determines whether or not DefWindowProc is called.
  • And pResult is used to send information back to the caller related to this specific notification. Exactly what that information is depends on which notification is being handled, as specified by the NMHDR struct passed via lParam.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • So the return value affects whether `DefWindowProc` gets called? – Ben Voigt Apr 01 '13 at 15:07
  • 1
    @BenVoigt That's not clear to me. I'd expect the return value to control whether or not the message is handed on to another party. But I'm not exactly clear on MFC message map routine. Do you know the answer? – David Heffernan Apr 01 '13 at 15:11
  • 1
    @BenVoigt I dug a bit deeper. You are right. The return value determines whether or not `DefWndProc` is called. – David Heffernan Apr 01 '13 at 15:19