Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CSpinButtonCtrl message handling to know up or down button is clicked

CSpinButtonCtrl message handling to know up or down button is clicked

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    A Ms
    wrote on last edited by
    #1

    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

    E 1 Reply Last reply
    0
    • A A Ms

      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

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      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;

      A 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        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;

        A Offline
        A Offline
        A Ms
        wrote on last edited by
        #3

        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. :(

        E 1 Reply Last reply
        0
        • A A Ms

          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. :(

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups