Using SpinButtonCtrl
-
To change the buttons' size of a SpinButton, I need to use CSpinButtonCtrl::Create() function. Now I added a SpinButton control on my dialog, what shall I do next?
|-|3llo Wo|2ld
Shuang. Wu wrote: what shall I do next? What is it that you are wanting to use the Spinner control for? Are you wanting it to be used with a Edit Control? Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
-
Shuang. Wu wrote: what shall I do next? What is it that you are wanting to use the Spinner control for? Are you wanting it to be used with a Edit Control? Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
-
Place code something like this (minus the lengthly comments) in your host dialog's OnInitDialog() function like:
// Sets the spinner control's buddy. This can be done either by using the
// below method (using GetDlgItem()) or passing the edit box's variable
// by reference like SetBuddy(&m_editBox);.
m_spinner.SetBuddy(GetDlgItem(IDC_EDIT_BOX));
// This next step would greatly depend on your personal preference according
// to your needs. I just done this to set a value in the edit box. This
// also should be done according to your program's needs.
GetDlgItem(IDC_EDIT_BOX)->SetWindowText("0");
// Next, I set the range of the spinner control. the first parameter is the
// minimum value and the second parameter is the maximum value.
m_spinner.SetRange(0, 100);
// Next, I set told the spinner to deal with the edit box in terms of
// integers. The boolean at the end is for determining whether the value
// should ever be signed or not.
m_spinner.SetDlgItemInt(IDC_EDIT_BOX, 0, FALSE);
That should do it! I hope this clarifies things for you and aids you in your programming efforts. Best of luck on your projects! :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
-
Place code something like this (minus the lengthly comments) in your host dialog's OnInitDialog() function like:
// Sets the spinner control's buddy. This can be done either by using the
// below method (using GetDlgItem()) or passing the edit box's variable
// by reference like SetBuddy(&m_editBox);.
m_spinner.SetBuddy(GetDlgItem(IDC_EDIT_BOX));
// This next step would greatly depend on your personal preference according
// to your needs. I just done this to set a value in the edit box. This
// also should be done according to your program's needs.
GetDlgItem(IDC_EDIT_BOX)->SetWindowText("0");
// Next, I set the range of the spinner control. the first parameter is the
// minimum value and the second parameter is the maximum value.
m_spinner.SetRange(0, 100);
// Next, I set told the spinner to deal with the edit box in terms of
// integers. The boolean at the end is for determining whether the value
// should ever be signed or not.
m_spinner.SetDlgItemInt(IDC_EDIT_BOX, 0, FALSE);
That should do it! I hope this clarifies things for you and aids you in your programming efforts. Best of luck on your projects! :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
Thx. But what i want is to change spin button contro's size. I know CSpinButtonCtrl::Create can do, see: BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ); ... Parameters ... rect Specifies the spin button contro's size and position. It can be either a CRect object or a RECT structure Thus, I want to know when I can call CSpinButtonCtrl::Create. Or, do you have any idea to change the spin button contro's size?
|-|3llo Wo|2ld
-
Thx. But what i want is to change spin button contro's size. I know CSpinButtonCtrl::Create can do, see: BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ); ... Parameters ... rect Specifies the spin button contro's size and position. It can be either a CRect object or a RECT structure Thus, I want to know when I can call CSpinButtonCtrl::Create. Or, do you have any idea to change the spin button contro's size?
|-|3llo Wo|2ld
Shuang. Wu wrote: Or, do you have any idea to change the spin button contro's size? You can use the
MoveWindow()
function to resize the control anytime. Here is MSDN Documentation on the function: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.movewindow.asp [^] Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp