From ffc18a6962f5b2c7c3c06601c02c29f8d65866c7 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 16 Sep 2016 19:23:26 +0100 Subject: [PATCH] Add OnNotify virtual function to class Window for WM_NOTIFY notifications Add OnNotify virtual function to class Window for WM_NOTIFY notifications Note that the result is returned via DWLP_MSGRESULT --- proppage.cc | 14 +++++++++++++- window.h | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/proppage.cc b/proppage.cc index 6b836409..8da1c52e 100644 --- a/proppage.cc +++ b/proppage.cc @@ -140,7 +140,18 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } case WM_NOTIFY: - switch (((NMHDR FAR *) lParam)->code) + { + NMHDR *pNmHdr = (NMHDR *) lParam; + + // offer to subclass first + LRESULT result = 0; + if (OnNotify (pNmHdr, &result)) + { + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, result); + return TRUE; + } + + switch (pNmHdr->code) { case PSN_APPLY: { @@ -261,6 +272,7 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } } + } break; case WM_COMMAND: { diff --git a/window.h b/window.h index ca6baa67..d8b712b8 100644 --- a/window.h +++ b/window.h @@ -138,6 +138,13 @@ public: return false; }; + virtual bool OnNotify (NMHDR *pNmHdr, LRESULT *pResult) + { + // Not processed by default. Override in derived classes to + // do something with command messages if you need to. + return false; + }; + RECT GetWindowRect() const; RECT GetClientRect() const; -- 2.43.5