This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 02/13] 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 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]