This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 02/13] Add OnNotify virtual function to class Window for WM_NOTIFY notifications
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon Turney <jon dot turney at dronecode dot org dot uk>
- Date: Sun, 5 Aug 2018 23:08:40 +0100
- Subject: [PATCH setup 02/13] Add OnNotify virtual function to class Window for WM_NOTIFY notifications
- References: <20180805220851.270212-1-jon.turney@dronecode.org.uk>
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 6b83640..8da1c52 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 ca6baa6..d8b712b 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.17.0