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. Spint control

Spint control

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 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.
  • R Offline
    R Offline
    RockyJames
    wrote on last edited by
    #1

    hi, I want write a sample application,having two edit boxes and one spincontrol.The spin control is set as buddy to the first editbox.I want to the setrange as 0 to 200.In the second edit box i want to enter data,the steps of increment tha has to be done in,first edidbox when click in spin control...Pls can any help how to address this..issue.. thanks in before james....

    _ 1 Reply Last reply
    0
    • R RockyJames

      hi, I want write a sample application,having two edit boxes and one spincontrol.The spin control is set as buddy to the first editbox.I want to the setrange as 0 to 200.In the second edit box i want to enter data,the steps of increment tha has to be done in,first edidbox when click in spin control...Pls can any help how to address this..issue.. thanks in before james....

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      RockyJames wrote:

      I want to the setrange as 0 to 200

      Use CSpinButtonCtrl::SetRange(short nLower,short nUpper);

      RockyJames wrote:

      the steps of increment tha has to be done in,first edidbox when click in spin control.

      Take the text from the second edit box and convert it to integer value. Now you can use CSpinButtonCtrl::SetPos(int nPos); for Spin control.

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      R 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        RockyJames wrote:

        I want to the setrange as 0 to 200

        Use CSpinButtonCtrl::SetRange(short nLower,short nUpper);

        RockyJames wrote:

        the steps of increment tha has to be done in,first edidbox when click in spin control.

        Take the text from the second edit box and convert it to integer value. Now you can use CSpinButtonCtrl::SetPos(int nPos); for Spin control.

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        R Offline
        R Offline
        RockyJames
        wrote on last edited by
        #3

        yeah i did this...i want to handle..(UDN_DELTAPOS)OnDeltaposSpin...of the spin control..Say for example the initial value in editbox one is 0 and the initial value in editbox two is 10..when the click the spincontrol.the value in first editbox has to updated based on the interval specified in second editbox..here..0 ,10 ,20 ,30 etc..how to do it..? thanks in before..

        _ 1 Reply Last reply
        0
        • R RockyJames

          yeah i did this...i want to handle..(UDN_DELTAPOS)OnDeltaposSpin...of the spin control..Say for example the initial value in editbox one is 0 and the initial value in editbox two is 10..when the click the spincontrol.the value in first editbox has to updated based on the interval specified in second editbox..here..0 ,10 ,20 ,30 etc..how to do it..? thanks in before..

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          RockyJames wrote:

          value in first editbox has to updated based on the interval specified in second editbox.

          void CYourDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
          {
          	LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR);
                  if(m_strEdit2.GetWindowTextLength()>0) //add this if condition
          	{
          	   CString s;
          	   m_strEdit1.GetWindowText (s);
          	   int i=atoi(s);
          	   CString t;
          	   m_strEdit2 .GetWindowText (t);
          	   int j=atoi(t);
          	   pNMUpDown ->iDelta =j;
          	   CString u;u.Format ("%d",i+j);
          	   m_st rEdit1.SetWindowText (u);
          	}
          	else   // Add this block
          	{
          		CString x;
          		x.Format ("%d",pNMUpDown ->iPos );
          		m_strEdit1.SetWindowText (x);
          	}
          	*pResult = 0;
          }
          

          In On InitDialog of your dialog you can put:

          CWnd *wnd=GetWindow (IDC_EDIT1);
          m_Spin.SetBuddy (wnd);
          m_Spin.SetRange (0,200);
          m_strEdit1.SetWindowText ("0");
          

          Let me know if this suits your needs now or even if there does exist some problem just inform me back... -- modified at 2:15 Saturday 23rd September, 2006

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          R 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            RockyJames wrote:

            value in first editbox has to updated based on the interval specified in second editbox.

            void CYourDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
            {
            	LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR);
                    if(m_strEdit2.GetWindowTextLength()>0) //add this if condition
            	{
            	   CString s;
            	   m_strEdit1.GetWindowText (s);
            	   int i=atoi(s);
            	   CString t;
            	   m_strEdit2 .GetWindowText (t);
            	   int j=atoi(t);
            	   pNMUpDown ->iDelta =j;
            	   CString u;u.Format ("%d",i+j);
            	   m_st rEdit1.SetWindowText (u);
            	}
            	else   // Add this block
            	{
            		CString x;
            		x.Format ("%d",pNMUpDown ->iPos );
            		m_strEdit1.SetWindowText (x);
            	}
            	*pResult = 0;
            }
            

            In On InitDialog of your dialog you can put:

            CWnd *wnd=GetWindow (IDC_EDIT1);
            m_Spin.SetBuddy (wnd);
            m_Spin.SetRange (0,200);
            m_strEdit1.SetWindowText ("0");
            

            Let me know if this suits your needs now or even if there does exist some problem just inform me back... -- modified at 2:15 Saturday 23rd September, 2006

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            R Offline
            R Offline
            RockyJames
            wrote on last edited by
            #5

            When i click..up arrow of the..spincontrol value has tobe increased and when i click down arrown value has to be decreased in first edit box,but there in both cases..value is increased...

            _ 1 Reply Last reply
            0
            • R RockyJames

              When i click..up arrow of the..spincontrol value has tobe increased and when i click down arrown value has to be decreased in first edit box,but there in both cases..value is increased...

              _ Offline
              _ Offline
              _AnsHUMAN_
              wrote on last edited by
              #6

              Put m_strEdit2.SetWindowText("1"); in On Init dialog. In OnDeltaPos.... add these lines.

              UDACCEL updown;
              CString t;
              m_strEdit2 .GetWindowText (t);
              int j=atoi(t);
              updown.nInc =j;
              updown.nSec =1;
              m_Spin.SetAccel (1,&updown);
              CString str;
              str.Format ("%d",pNMUpDown ->iPos );
              m_strEdit1.SetWindowText (str);
              

              I haven't tested the code...

              Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

              R 1 Reply Last reply
              0
              • _ _AnsHUMAN_

                Put m_strEdit2.SetWindowText("1"); in On Init dialog. In OnDeltaPos.... add these lines.

                UDACCEL updown;
                CString t;
                m_strEdit2 .GetWindowText (t);
                int j=atoi(t);
                updown.nInc =j;
                updown.nSec =1;
                m_Spin.SetAccel (1,&updown);
                CString str;
                str.Format ("%d",pNMUpDown ->iPos );
                m_strEdit1.SetWindowText (str);
                

                I haven't tested the code...

                Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                R Offline
                R Offline
                RockyJames
                wrote on last edited by
                #7

                still it is not working properly..frined..

                H 1 Reply Last reply
                0
                • R RockyJames

                  still it is not working properly..frined..

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  What do you want,exactly? You have two editboxs and a spin control that it sets to 0..200 then?

                  _**


                  **_

                  WhiteSky


                  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