CSpinButtonCtrl message handling to know up or down button is clicked
-
I have added 2 CMFCSpinButtonCtrl to my ribbon menu now I want know how could I handle a message in my view class to see which spin control and which button of that control (up/down) is pressed I know it is something related to UDN_DELTAPOS But I don't know How To implement it
-
I have added 2 CMFCSpinButtonCtrl to my ribbon menu now I want know how could I handle a message in my view class to see which spin control and which button of that control (up/down) is pressed I know it is something related to UDN_DELTAPOS But I don't know How To implement it
Does the following work ? :) :
BEGIN_MESSAGE_MAP(CDrawView, CView)
//{{AFX_MSG_MAP(CDrawView)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnUpDown)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()void CDrawView::OnUpDown(NMHDR *pNMHDR, LRESULT *result)
{
NM_UPDOWN* pUpDown = (NM_UPDOWN*) pNMHDR;bool bUp = 0 < pUpDown->iDelta;
...
}virtual void BeHappy() = 0;
-
Does the following work ? :) :
BEGIN_MESSAGE_MAP(CDrawView, CView)
//{{AFX_MSG_MAP(CDrawView)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnUpDown)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()void CDrawView::OnUpDown(NMHDR *pNMHDR, LRESULT *result)
{
NM_UPDOWN* pUpDown = (NM_UPDOWN*) pNMHDR;bool bUp = 0 < pUpDown->iDelta;
...
}virtual void BeHappy() = 0;
-
Thanks Your code structure seems correct but unfortunately the UDN_DELTAPOS message didn't work I also tested WM_VSCROLL with ON_NOTIFY but it didn't work too. :(
0. Try to analyze the sent messages to the view window by clicking using Spy++ 1. Elsewise - Derivate your own control from CMFCSpinButtonCtrl (like CMFCRibbonSpinButtonCtrl ;) ) to implement your own reaction for:
afx_msg void CYourCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if (CMFCSpinButtonCtrl::m_bIsButtonPressedUp) {
// ... for example a message at MainFrame
} else
if (CMFCSpinButtonCtrl::m_bIsButtonPressedDown) {
// ... for example a message at MainFrame
}CMFCSpinButtonCtrl::OnLButtonUp(nFlags, point);
}virtual void BeHappy() = 0;
modified on Thursday, March 11, 2010 5:12 AM