Spin Control 
Author Message
 Spin Control

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 19:25:25 GMT  
 Spin Control

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?

CSpinBUttonCtrl::GetPos returns an INT value representing, "...The current
position in the low-order word. The high-order word is nonzero if an error
occurred". Have a look at CString::Format and possibly the LOWORD and HIWORD
macros. You may even have some luck using GetBuddy::GetWindowText.
--
Jeff Partch [VC++ MVP]


Mon, 12 Sep 2005 19:35:06 GMT  
 Spin Control
Try something like this:

int val = m_numchanspin.GetPos();

I use a method Msg(TCHAR *szFormat, ...), so
 Msg(TEXT("val=%d"),m_numchanspin.GetPos());

Quote:
>-----Original Message-----
>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 19:44:57 GMT  
 Spin Control
No matter, I'm stupid :)


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 19:38:49 GMT  
 Spin Control
here are some macros that will make your life easier...

#define swtf(a,b,c)      cstr.Format ( "%.*f", c, b ); a .
SetWindowText (cstr);
#define swti(a,b)        cstr.Format ( "%d"     , b ); a .
SetWindowText (cstr);

#define gwtf(a,b)    a . GetWindowText (cstr); b = (float)
atof ( (LPCTSTR) cstr )
#define gwti(a,b)    a . GetWindowText (cstr); b =        
atoi ( (LPCTSTR) cstr )

use:
swtf ( m_EditIfstart    , fd4pch-> Gates [4].Start, 2 );
parameter c with 2 means to show 2 decimal places



Mon, 12 Sep 2005 20:43:46 GMT  
 Spin Control
Get the text of the edit "buddy" control with GetWindowText().


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 22:20:46 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. adding spin control to list control

2. spin control,edit control

3. Possible to remove spin control from a tab control

4. Problem: Spin Control always selects all text in edit control

5. help! associating Spin Control with Slider Control

6. Spin control effecting slider control.

7. Date/Time Edit control with spin control

8. Spin control out of control

9. Spin Control & DAO

10. DAO and Spin Control

11. Spin Control and DAO

12. Spin Control and DAO

 

 
Powered by phpBB® Forum Software