Nikolay Sivov : comctl32/monthcal: Move MCN_SELCHANGE/ MCN_SELECT notifications to helpers.

Alexandre Julliard julliard at winehq.org
Fri Oct 2 11:02:20 CDT 2009


Module: wine
Branch: master
Commit: eb87332f144ac635f417a96c5b6ee9fe26b94b52
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eb87332f144ac635f417a96c5b6ee9fe26b94b52

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Thu Oct  1 22:12:21 2009 +0400

comctl32/monthcal: Move MCN_SELCHANGE/MCN_SELECT notifications to helpers.

---

 dlls/comctl32/monthcal.c |   59 ++++++++++++++++++++++++---------------------
 1 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index ed454da..e9aeac6 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -130,6 +130,33 @@ static const WCHAR themeClass[] = { 'S','c','r','o','l','l','b','a','r',0 };
 
 /* helper functions  */
 
+/* send a single MCN_SELCHANGE notification */
+static inline void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
+{
+    NMSELCHANGE nmsc;
+
+    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
+    nmsc.nmhdr.code     = MCN_SELCHANGE;
+    nmsc.stSelStart     = infoPtr->minSel;
+    nmsc.stSelEnd       = infoPtr->maxSel;
+    SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
+}
+
+/* send a single MCN_SELECT notification */
+static inline void MONTHCAL_NotifySelect(const MONTHCAL_INFO *infoPtr)
+{
+    NMSELCHANGE nmsc;
+
+    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
+    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
+    nmsc.nmhdr.code     = MCN_SELECT;
+    nmsc.stSelStart     = infoPtr->minSel;
+    nmsc.stSelEnd       = infoPtr->maxSel;
+
+    SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
+}
+
 /* returns the number of days in any given month, checking for leap days */
 /* january is 1, december is 12 */
 int MONTHCAL_MonthLength(int month, int year)
@@ -1478,23 +1505,14 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
   }
   case MCHT_TODAYLINK:
   {
-    NMSELCHANGE nmsc;
-
     infoPtr->firstSelDay  = infoPtr->todaysDate.wDay;
     infoPtr->curSel = infoPtr->todaysDate;
     infoPtr->minSel = infoPtr->todaysDate;
     infoPtr->maxSel = infoPtr->todaysDate;
     InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
 
-    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
-    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
-    nmsc.nmhdr.code     = MCN_SELCHANGE;
-    nmsc.stSelStart     = infoPtr->minSel;
-    nmsc.stSelEnd       = infoPtr->maxSel;
-    SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
-
-    nmsc.nmhdr.code     = MCN_SELECT;
-    SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
+    MONTHCAL_NotifySelectionChange(infoPtr);
+    MONTHCAL_NotifySelect(infoPtr);
     return 0;
   }
   case MCHT_CALENDARDATE:
@@ -1514,7 +1532,6 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 static LRESULT
 MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 {
-  NMSELCHANGE nmsc;
   NMHDR nmhdr;
   BOOL redraw = FALSE;
   MCHITTESTINFO ht;
@@ -1561,23 +1578,9 @@ MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
 
     /* send MCN_SELCHANGE only if new date selected */
     if (!MONTHCAL_IsDateEqual(&sel, &ht.st))
-    {
-        nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
-        nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
-        nmsc.nmhdr.code     = MCN_SELCHANGE;
-        nmsc.stSelStart     = infoPtr->minSel;
-        nmsc.stSelEnd       = infoPtr->maxSel;
-
-        SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
-    }
+        MONTHCAL_NotifySelectionChange(infoPtr);
 
-    nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
-    nmsc.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
-    nmsc.nmhdr.code     = MCN_SELECT;
-    nmsc.stSelStart     = infoPtr->minSel;
-    nmsc.stSelEnd       = infoPtr->maxSel;
-
-    SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
+    MONTHCAL_NotifySelect(infoPtr);
 
     return 0;
   }




More information about the wine-cvs mailing list