MFC中的Spin control控件对应WTL中的CUpDownCtrl控件,CUpDownCtrl控件通过SetBuddy()方法绑定需要上下选择控件的窗口,典型的就是Edit控件。下面来看代码:
WTL::CRichEditCtrlm_recCount;
WTL::CUpDownCtrlm_upcCount;
WTL::CRectm_rcCount;

//初始化
m_rcCount=WTL::CRect(0,0,width,20);

//
voidSetupEdit()


{
//Countrichedit
m_recCount.Create(
*this,
m_rcCount,
L"",
WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NUMBER|ES_LEFT,
0);

m_upcCount.Create(
*this,
m_rcCount,
L"",
WS_CHILD|WS_VISIBLE|UDS_ALIGNRIGHT|UDS_AUTOBUDDY|UDS_SETBUDDYINT,
0);
m_upcCount.SetBuddy(m_recCount);
m_upcCount.SetRange(1,m_maxCount);
m_upcCount.SetPos(1);
}