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. Notifiation Messages for CSpinButtonCtrl in MFC

Notifiation Messages for CSpinButtonCtrl in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++career
13 Posts 3 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.
  • S Sampath579

    Hi I created a control in my MFC application as follows:

    CSpinButtonCtrl m_spin;
    m_spin.Create(UDS_HORZ, CRect(0, 0, 50, 50), this, 1011);
    m_spin.ShowWindow(1);

    which created a spin control with two button with left arrow and right arrow. Now i want to perform some job based on the user clicks on these two buttons. I tried by adding notification message in Message map as follows:

    ON_NOTIFY(NM_CLICK, IDC_SPIN1, OnDropDown)

    The above message dint called my OnDropDown(). I tried adding ON_WM_HSCROLL(), it worked. The function OnHScroll is getting executed when i click on right or left arrow buttons in spin control. But what my fear is, in near future i may also add a scroll bars (horiz and veritcal) in my application. That time this may get conflict with my spin control. So, i am looking for a message which will notify me when left or arrow arrow is invoked on spin control.

    J Offline
    J Offline
    Jochen Arndt
    wrote on last edited by
    #2

    The notification message send to the parent uses the UDN_DELTAPOS notification code (Windows)[^]

    S 1 Reply Last reply
    0
    • S Sampath579

      Hi I created a control in my MFC application as follows:

      CSpinButtonCtrl m_spin;
      m_spin.Create(UDS_HORZ, CRect(0, 0, 50, 50), this, 1011);
      m_spin.ShowWindow(1);

      which created a spin control with two button with left arrow and right arrow. Now i want to perform some job based on the user clicks on these two buttons. I tried by adding notification message in Message map as follows:

      ON_NOTIFY(NM_CLICK, IDC_SPIN1, OnDropDown)

      The above message dint called my OnDropDown(). I tried adding ON_WM_HSCROLL(), it worked. The function OnHScroll is getting executed when i click on right or left arrow buttons in spin control. But what my fear is, in near future i may also add a scroll bars (horiz and veritcal) in my application. That time this may get conflict with my spin control. So, i am looking for a message which will notify me when left or arrow arrow is invoked on spin control.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #3

      For spin button control you can use the [UDN_DELTAPOS notification code (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/bb759903(v=vs.85).aspx)

      1 Reply Last reply
      0
      • J Jochen Arndt

        The notification message send to the parent uses the UDN_DELTAPOS notification code (Windows)[^]

        S Offline
        S Offline
        Sampath579
        wrote on last edited by
        #4

        Sorry i tried this as follows

        ON_NOTIFY_REFLECT(UDN_DELTAPOS,OnSpinContol)

        Its throws syntax error and could not find any sample in google to declare the message.

        V J 2 Replies Last reply
        0
        • S Sampath579

          Sorry i tried this as follows

          ON_NOTIFY_REFLECT(UDN_DELTAPOS,OnSpinContol)

          Its throws syntax error and could not find any sample in google to declare the message.

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #5

          In what class did you implement it? Please, post the exact code snippets!

          S 1 Reply Last reply
          0
          • S Sampath579

            Sorry i tried this as follows

            ON_NOTIFY_REFLECT(UDN_DELTAPOS,OnSpinContol)

            Its throws syntax error and could not find any sample in google to declare the message.

            J Offline
            J Offline
            Jochen Arndt
            wrote on last edited by
            #6

            That is for handling the message by the control class itself when having it derived. To handle the message in the parent do it like you have done already:

            ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaPos)

            S 1 Reply Last reply
            0
            • V Victor Nijegorodov

              In what class did you implement it? Please, post the exact code snippets!

              S Offline
              S Offline
              Sampath579
              wrote on last edited by
              #7

              BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
              ON_NOTIFY_REFLECT(UDN_DELTAPOS,OnSpinContol)
              END_MESSAGE_MAP()

              void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
              {

              }

              V 1 Reply Last reply
              0
              • J Jochen Arndt

                That is for handling the message by the control class itself when having it derived. To handle the message in the parent do it like you have done already:

                ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaPos)

                S Offline
                S Offline
                Sampath579
                wrote on last edited by
                #8

                Even tried below one, but no luck. :(

                BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN, OnSpinContol)
                END_MESSAGE_MAP()

                void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                {

                }

                V J 2 Replies Last reply
                0
                • S Sampath579

                  BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                  ON_NOTIFY_REFLECT(UDN_DELTAPOS,OnSpinContol)
                  END_MESSAGE_MAP()

                  void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                  {

                  }

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #9

                  CMyClass seems to be a parent/owner of the spin control. So there must be ON_NOTIFY macro, not a ON_NOTIFY_REFLECT

                  1 Reply Last reply
                  0
                  • S Sampath579

                    Even tried below one, but no luck. :(

                    BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                    ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN, OnSpinContol)
                    END_MESSAGE_MAP()

                    void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                    {

                    }

                    V Offline
                    V Offline
                    Victor Nijegorodov
                    wrote on last edited by
                    #10

                    Sampath579 wrote:

                    Even tried below one, but no luck. :(

                    BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                    ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN, OnSpinContol)
                    END_MESSAGE_MAP()

                    void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                    {

                    }

                    1. Define "no luck". 2. Do you pass the correct control ID (IDC_SPIN)?

                    S 1 Reply Last reply
                    0
                    • S Sampath579

                      Even tried below one, but no luck. :(

                      BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                      ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN, OnSpinContol)
                      END_MESSAGE_MAP()

                      void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                      {

                      }

                      J Offline
                      J Offline
                      Jochen Arndt
                      wrote on last edited by
                      #11

                      It is very probably sourced by the creation of your spin control:

                      m_spin.Create(UDS_HORZ, CRect(0, 0, 50, 50), this, 1011);

                      That misses the common window style flags like WS_CHILD | WS_VISIBLE | WS_TABSTOP. Just out of interest: Why are you creating your controls manually instead of using resource templates? With templates the default settings are initially set in the resource editor so that such errors did not occur.

                      S 1 Reply Last reply
                      0
                      • J Jochen Arndt

                        It is very probably sourced by the creation of your spin control:

                        m_spin.Create(UDS_HORZ, CRect(0, 0, 50, 50), this, 1011);

                        That misses the common window style flags like WS_CHILD | WS_VISIBLE | WS_TABSTOP. Just out of interest: Why are you creating your controls manually instead of using resource templates? With templates the default settings are initially set in the resource editor so that such errors did not occur.

                        S Offline
                        S Offline
                        Sampath579
                        wrote on last edited by
                        #12

                        Hey Thanks.. Finally its working. The very first thing is i am new to MFC and second is i am creating all dynamic windows and controls based on user input.

                        1 Reply Last reply
                        0
                        • V Victor Nijegorodov

                          Sampath579 wrote:

                          Even tried below one, but no luck. :(

                          BEGIN_MESSAGE_MAP(CMyClass, CScrollView)
                          ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN, OnSpinContol)
                          END_MESSAGE_MAP()

                          void CMyClass::OnSpinContol(NMHDR *pNMHDR, LRESULT *pResult)
                          {

                          }

                          1. Define "no luck". 2. Do you pass the correct control ID (IDC_SPIN)?

                          S Offline
                          S Offline
                          Sampath579
                          wrote on last edited by
                          #13

                          Hey Thanks Victor. Its working now.

                          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