?? spin control.txt
字號:
定義spin button control的一個Control類型變量m_ctlSpin
m_ctlSpin.SetBuddy(GetDlgItem(IDC_EDIT));//IDC_EDIT是你要關聯(lián)的
//Editbox
m_ctlSpin.SetRange(2,100);
ctrl+d,設置tab順序,edit下一個spin控件與edit綁定在一起。
初始化時,spin1.setrange(0,100);
首先,要讓Spin Control的Tap Order緊跟著Edit Control(就是說,Spin Control的Tap Order是Edit Control的Tap Order加1)。
然后,設置Spin Control的Auto Buddy和Set Buddy Integer屬性為True。
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
注意要設置*pResult = 1;
void CYourDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown =(NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
TCHAR szText[MAX_INPUT];
GetDlgItemText(IDC_EDIT,szText,MAX_INPUT);
sprintf(szText,"%.1f",atof(szText)+ 0.1 * pNMUpDown->iDelta);
SetDlgItemText(IDC_EDIT,szText);
*pResult = 1;
}
OnLButtonDown函數:
void CMySpinButtonCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int nRow;
int nUpper;
CMySpinButtonCtrl::GetRange(nRow, nUpper);
/*
*判斷編輯框中的輸入是否合法
*/
CString strNum;
CMySpinButtonCtrl::GetBuddy()->GetWindowText(strNum);
if ( g_IsNumber(strNum) ==FALSE )
{
MessageBox("請輸入合法的數字");
return;
}
else
{
CRect Rect;
CMySpinButtonCtrl::GetWindowRect (&Rect);
if( strNum.Find('.') > 0 )
{
int nDotpos = strNum.Find('.');
int nLength = strNum.GetLength();
strNum = strNum.Left(nDotpos+1);
int pos = atoi(strNum);
if(point.y <((Rect.bottom-Rect.top)/2))
{
CMySpinButtonCtrl::SetPos(pos);
}
else
{
CMySpinButtonCtrl::SetPos(pos + 1);
}
}
else
{
int pos = atoi(strNum);
CMySpinButtonCtrl::SetPos(pos);
}
}
CSpinButtonCtrl::OnLButtonDown(nFlags, point);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -