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. Spin control , it's possible to know when the control is released?

Spin control , it's possible to know when the control is released?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++
12 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.
  • T Offline
    T Offline
    timbk
    wrote on last edited by
    #1

    hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?

    C T 2 Replies Last reply
    0
    • T timbk

      hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      From commctrl.h:

      #define NM_RELEASEDCAPTURE (NM_FIRST-16)

      See if you get this notification with ON_NOTIFY

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

      T 1 Reply Last reply
      0
      • C Code o mat

        From commctrl.h:

        #define NM_RELEASEDCAPTURE (NM_FIRST-16)

        See if you get this notification with ON_NOTIFY

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

        T Offline
        T Offline
        timbk
        wrote on last edited by
        #3

        I'm not sure to understand what you mean, perhpas because I'm newbie :( . I looked for ON_NOTIFY and the unique reference is:

        ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)

        no references for NM_RELEASEDCAPTURE,of course inside of commctrl.h i can find this line that you posted:

        #define NM_RELEASEDCAPTURE (NM_FIRST-16

        but I don't know what to do with this, can you explain a little more?

        C 1 Reply Last reply
        0
        • T timbk

          I'm not sure to understand what you mean, perhpas because I'm newbie :( . I looked for ON_NOTIFY and the unique reference is:

          ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)

          no references for NM_RELEASEDCAPTURE,of course inside of commctrl.h i can find this line that you posted:

          #define NM_RELEASEDCAPTURE (NM_FIRST-16

          but I don't know what to do with this, can you explain a little more?

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Try this:

          ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SPIN1, OnSpinReleasedCapture)

          The OnSpinReleaseCapture method should look the same as OnDeltaposSpin1, am not sure how it looks in VS6 anymore, something like this probably:

          void OnSpinReleaseCapture(LPNMHDR lpNMHDR, LRESULT *pResult)

          . Am not sure you will get this called but it is worht a try i guess.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

          T 1 Reply Last reply
          0
          • C Code o mat

            Try this:

            ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SPIN1, OnSpinReleasedCapture)

            The OnSpinReleaseCapture method should look the same as OnDeltaposSpin1, am not sure how it looks in VS6 anymore, something like this probably:

            void OnSpinReleaseCapture(LPNMHDR lpNMHDR, LRESULT *pResult)

            . Am not sure you will get this called but it is worht a try i guess.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

            T Offline
            T Offline
            timbk
            wrote on last edited by
            #5

            Thanks for your answer, ok I've trying, I did this: In the header file CalibracionDlg.h

            afx\_msg void OnDeltaposSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult);
            afx\_msg void OnReleasedCaptureSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult); 
            

            In the source file Calibraciondlg.cpp

            ON\_NOTIFY(UDN\_DELTAPOS, IDC\_SPIN1, OnDeltaposSPIN1)
            ON\_NOTIFY(NM\_RELEASEDCAPTURE, IDC\_SPIN1, OnReleasedCaptureSPIN1)
            

            and the methods

            void CCalibracionDlg::OnDeltaposSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
            {

            NM\_UPDOWN\* pNMUpDown = (NM\_UPDOWN\*)pNMHDR;
            // TODO: Add your control notification handler code here
            //some code
            

            }

            void CCalibracionDlg::OnReleasedCaptureSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
            {
            GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);//just to see if it works.
            }

            the compiler doesn't show any erros, but when I execute , nothing, when the control is released nothing happens. may be i forgot something?

            C 1 Reply Last reply
            0
            • T timbk

              Thanks for your answer, ok I've trying, I did this: In the header file CalibracionDlg.h

              afx\_msg void OnDeltaposSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult);
              afx\_msg void OnReleasedCaptureSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult); 
              

              In the source file Calibraciondlg.cpp

              ON\_NOTIFY(UDN\_DELTAPOS, IDC\_SPIN1, OnDeltaposSPIN1)
              ON\_NOTIFY(NM\_RELEASEDCAPTURE, IDC\_SPIN1, OnReleasedCaptureSPIN1)
              

              and the methods

              void CCalibracionDlg::OnDeltaposSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
              {

              NM\_UPDOWN\* pNMUpDown = (NM\_UPDOWN\*)pNMHDR;
              // TODO: Add your control notification handler code here
              //some code
              

              }

              void CCalibracionDlg::OnReleasedCaptureSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
              {
              GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);//just to see if it works.
              }

              the compiler doesn't show any erros, but when I execute , nothing, when the control is released nothing happens. may be i forgot something?

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              I have VS2003, i did a quick dialog based app and used the event handler wizard (right clicked the spin and selected 'add event handler') to add a handler for NM_RELEASEDCAPTURE, it generates the same code as you used (except for the custom parts of course) so it should be correct, however the event handler never seems to fire. Confusing... it says here[^] too that it is -suposedly- sent. Maybe this requires a deeper googling act.

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

              T 1 Reply Last reply
              0
              • C Code o mat

                I have VS2003, i did a quick dialog based app and used the event handler wizard (right clicked the spin and selected 'add event handler') to add a handler for NM_RELEASEDCAPTURE, it generates the same code as you used (except for the custom parts of course) so it should be correct, however the event handler never seems to fire. Confusing... it says here[^] too that it is -suposedly- sent. Maybe this requires a deeper googling act.

                > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

                T Offline
                T Offline
                timbk
                wrote on last edited by
                #7

                Ok, thanks a lot for your time, yes it's easier in VS2003, but is not my choice to use VC6 , i have to, so i gonna keep searching.

                C 1 Reply Last reply
                0
                • T timbk

                  Ok, thanks a lot for your time, yes it's easier in VS2003, but is not my choice to use VC6 , i have to, so i gonna keep searching.

                  C Offline
                  C Offline
                  Code o mat
                  wrote on last edited by
                  #8

                  This might be re-inventing the wheel but try this:

                  class CMySpin: public CSpinButtonCtrl
                  {
                  protected:
                  DECLARE_MESSAGE_MAP()
                  afx_msg void OnCaptureChanged(CWnd *pWnd);
                  };

                  and the implementation:

                  BEGIN_MESSAGE_MAP(CMySpin, CSpinButtonCtrl)
                  ON_WM_CAPTURECHANGED()
                  END_MESSAGE_MAP()

                  void CMySpin::OnCaptureChanged(CWnd *pWnd)
                  {
                  CSpinButtonCtrl::OnCaptureChanged(pWnd);
                  if (pWnd != this)
                  {
                  NMHDR NMHdr;
                  NMHdr.code = NM_RELEASEDCAPTURE;
                  NMHdr.hwndFrom = m_hWnd;
                  NMHdr.idFrom = GetDlgCtrlID();
                  GetParent()->SendMessage(WM_NOTIFY, NMHdr.idFrom, (LPARAM)&NMHdr);
                  }
                  }

                  use a CMySpin as a control variable for your spin button in your dialog. (You might need to modify the code to compile under VS6, don't know what has changed since VS6)

                  > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

                  T 1 Reply Last reply
                  0
                  • C Code o mat

                    This might be re-inventing the wheel but try this:

                    class CMySpin: public CSpinButtonCtrl
                    {
                    protected:
                    DECLARE_MESSAGE_MAP()
                    afx_msg void OnCaptureChanged(CWnd *pWnd);
                    };

                    and the implementation:

                    BEGIN_MESSAGE_MAP(CMySpin, CSpinButtonCtrl)
                    ON_WM_CAPTURECHANGED()
                    END_MESSAGE_MAP()

                    void CMySpin::OnCaptureChanged(CWnd *pWnd)
                    {
                    CSpinButtonCtrl::OnCaptureChanged(pWnd);
                    if (pWnd != this)
                    {
                    NMHDR NMHdr;
                    NMHdr.code = NM_RELEASEDCAPTURE;
                    NMHdr.hwndFrom = m_hWnd;
                    NMHdr.idFrom = GetDlgCtrlID();
                    GetParent()->SendMessage(WM_NOTIFY, NMHdr.idFrom, (LPARAM)&NMHdr);
                    }
                    }

                    use a CMySpin as a control variable for your spin button in your dialog. (You might need to modify the code to compile under VS6, don't know what has changed since VS6)

                    > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

                    T Offline
                    T Offline
                    timbk
                    wrote on last edited by
                    #9

                    Ok, sorry if my questions are too basics, so I already add the class CMyspin to the proyect as you decribed, and i added a control variable " m_Spin1" of CMySpin type to the spin 1 control , compiled with no errors, so wich is the next step? how can i catch the event of control released?

                    1 Reply Last reply
                    0
                    • T timbk

                      hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?

                      T Offline
                      T Offline
                      timbk
                      wrote on last edited by
                      #10

                      :-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file

                      afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

                      Source file Message map

                      ON_WM_VSCROLL()

                      And handler

                      void CCalibracionDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
                      {
                      if(SB_ENDSCROLL == nSBCode)
                      {
                      if(pScrollBar->m_hWnd == m_Spin1m_hWnd)
                      {
                      // the position was not changed, so...
                      AfxMessageBox( _T("Termino el Spin1!!!") );
                      return;
                      }
                      if(pScrollBar->m_hWnd == m_Spin2.m_hWnd)
                      {
                      // the position was not changed, so...
                      AfxMessageBox( _T("Termino el Spin2!!!") );
                      return;
                      }
                      }
                      }

                      C 2 Replies Last reply
                      0
                      • T timbk

                        :-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file

                        afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

                        Source file Message map

                        ON_WM_VSCROLL()

                        And handler

                        void CCalibracionDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
                        {
                        if(SB_ENDSCROLL == nSBCode)
                        {
                        if(pScrollBar->m_hWnd == m_Spin1m_hWnd)
                        {
                        // the position was not changed, so...
                        AfxMessageBox( _T("Termino el Spin1!!!") );
                        return;
                        }
                        if(pScrollBar->m_hWnd == m_Spin2.m_hWnd)
                        {
                        // the position was not changed, so...
                        AfxMessageBox( _T("Termino el Spin2!!!") );
                        return;
                        }
                        }
                        }

                        C Offline
                        C Offline
                        Code o mat
                        wrote on last edited by
                        #11

                        Yaay for google! :) :thumbsup:

                        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

                        1 Reply Last reply
                        0
                        • T timbk

                          :-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file

                          afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

                          Source file Message map

                          ON_WM_VSCROLL()

                          And handler

                          void CCalibracionDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
                          {
                          if(SB_ENDSCROLL == nSBCode)
                          {
                          if(pScrollBar->m_hWnd == m_Spin1m_hWnd)
                          {
                          // the position was not changed, so...
                          AfxMessageBox( _T("Termino el Spin1!!!") );
                          return;
                          }
                          if(pScrollBar->m_hWnd == m_Spin2.m_hWnd)
                          {
                          // the position was not changed, so...
                          AfxMessageBox( _T("Termino el Spin2!!!") );
                          return;
                          }
                          }
                          }

                          C Offline
                          C Offline
                          Code o mat
                          wrote on last edited by
                          #12

                          Yeey for google! :) :thumbsup:

                          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<

                          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