SpinControl 
Author Message
 SpinControl

I am having an issue with the SpinControl.  I created a spin control via the
resource editor in MS VC++ 6 and called it ID_SPIN.  I need to know how to
associate it with a member variable in my dialog class.  I am using the
following

class CSampleDialog : public CDialog
{
    CSpinButtonCtrl m_UpDown;
public:
    ect.....

I want to initialize the control in in the dialog's OnInitDialog fuction,
but don't know how to do so.  I can use the following

CSpinButtonCtrl *UpDown = (CSpinButtonCtrl *) GetDlgItem(ID_SPIN);

but it loses scope and I would have to redo this in the OnVScroll as well.
Can someone please help.

Thanks in advance,
Brian



Sun, 11 Sep 2005 05:30:28 GMT  
 SpinControl

Quote:
>I am having an issue with the SpinControl.  I created a spin control via the
>resource editor in MS VC++ 6 and called it ID_SPIN.  I need to know how to
>associate it with a member variable in my dialog class.

Brian,

You normally just use ClassWizard to attach a control variable to the
dialog control. The Class Wizard (or the equivalent functionality in
VC7) just adds a DDX line to the DoDataExchange method to attach the
dialog control to the control variable.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Sun, 11 Sep 2005 09:53:34 GMT  
 SpinControl
I'm using a CSpinButtonCtrl and I need to get it's value. I can increment
and decrement the value in the buddy using the arrows, but when I try and
GetPos() of the spinner, and output it, all I get is a box character. Here
is my code:

CString msg = m_numchanspin.GetPos();
AfxMessageBox(msg);

Should be simple. I just want a window to pop up with the value. But I'm
getting a box character instead. Anyone?

Cedric



Mon, 12 Sep 2005 18:57:11 GMT  
 SpinControl
I am a bit of a newbie, but this is how it should work.

char str[255];
int pos;
pos = LOWORD(m_numchanspin.GetPos());
wsprintf(str, "%d", pos);
MessageBox(str, "Position");

Once again, I am a little new at this, but I do know that you have to use
LOWORD to get the value.
Hope this helps.

Brian


Quote:
> I'm using a CSpinButtonCtrl and I need to get it's value. I can increment
> and decrement the value in the buddy using the arrows, but when I try and
> GetPos() of the spinner, and output it, all I get is a box character. Here
> is my code:

> CString msg = m_numchanspin.GetPos();
> AfxMessageBox(msg);

> Should be simple. I just want a window to pop up with the value. But I'm
> getting a box character instead. Anyone?

> Cedric



Mon, 12 Sep 2005 21:03:11 GMT  
 SpinControl

Quote:
>I'm using a CSpinButtonCtrl and I need to get it's value. I can increment
>and decrement the value in the buddy using the arrows, but when I try and
>GetPos() of the spinner, and output it, all I get is a box character. Here
>is my code:

>CString msg = m_numchanspin.GetPos();

Cedric,

I don't know how you got the above line of code to compile, but that's
your problem.

You need to convert the integer return value from GetPos into a
string. For example:

CString msg;
msg.Format( "%d", m_numchanspin.GetPos() );
AfxMessageBox(msg);

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 12 Sep 2005 21:23:59 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. spincontrol,editcontrol

2. SpinControl Help!! It's urgent!

 

 
Powered by phpBB® Forum Software