只能是整数
用 SetBuddy 设置你的 CEdit 伙伴

解决方案 »

  1.   

    初始化:
    pSpinCtrl->SetRange(0,120) //设置范围
    pSpinCtrl->SetPos(60)    //
    响应消息:
    void CMyDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
    {
    // TODO: Add your message handler code here and/or call default
    if(nSBCode==SB_ENDSCROLL){
    return;
    }
    if((pScrollBar->GetDlgCtrlID()==IDC_MYSPIN))
    {
    CString strValue;
    if(nPos>=60)
      strValue.Format("%3.1f",(float)(nPos-60)/10);
    else 
                      strValue.Format("-%3.1f",(float)(60-nPos)/10);
    ((CSpinButtonCtrl*)pScrollBar)->GetBuddy()->
    SetWindowText(strValue);
    }
    UpdateData(TRUE);
    CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
    }