void CParsedEdit::OnVScroll(UINT nSBCode, UINT, CScrollBar*) { int nDelta = 0; if (nSBCode == SB_LINEDOWN) nDelta = -1; else if (nSBCode == SB_LINEUP) nDelta = +1; else return; // nothing special // set the focus to this edit item and select it all SetFocus(); //Get the number in the control. BOOL bOk; int nOld = GetParent()->GetDlgItemInt(GetDlgCtrlID(), &bOk); if (bOk) { // The MuScrl32 control also supports range checking // for this example, we just prevent overflow int nNew = nOld + nDelta; if (nNew >= 0 && nNew <= 32767) GetParent()->SetDlgItemInt(GetDlgCtrlID(), nNew); else bOk = FALSE; } if (!bOk) OnBadInput(); SetSel(0, -1); }
void CuParseEditCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { WORD type; if (nChar < 0x20) type = PES_ALL; // always allow control chars else if (_istalnum(nChar) && !_istalpha(nChar)) type = PES_NATURAL; else if (_istalpha(nChar)) type = PES_LETTERS; else { CString strText; GetWindowText (strText); int nLen = strText.GetLength (); if ((TCHAR)nChar == _T('-') && (m_wParseStyle & PES_INTEGER) && nLen == 0) type = PES_INTEGER; else if ((TCHAR)nChar == _T('-') && (m_wParseStyle & PES_INTEGER) && nLen > 0) { int nStartChar, nEndChar; GetSel(nStartChar, nEndChar); if (nStartChar == 0 && nEndChar == 0 && strText.Find (_T('-'))== -1) type = PES_INTEGER; else if (nStartChar == 0 && nEndChar > 0) { // // If partial or all text is selected from the starting position // then allow typing the minus sign ('-') even if it has already // been in the edit. type = PES_INTEGER; } else type = PES_OTHERCHARS; } else type = PES_OTHERCHARS; } if (m_wParseStyle & type) { CEdit::OnChar(nChar, nRepCnt, nFlags); // permitted } else { // // Illegal character - inform parent OnBadInput(); } }
void wcSliderButton::OnUpdate () { TCHAR buf[512]; GetWindowText (buf, sizeof( buf ) / sizeof(TCHAR)); int Value = atoi(buf); if ( Value >= m_Min && Value <= m_Max ) { m_Pos = Value; CWnd *pParent = GetParent(); if ( pParent ) pParent->SendMessage(CSP_DELTAPOS, m_Pos, (WPARAM) GetDlgCtrlID()); } else OnBadInput(); }
void CParsedEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { WORD type; if (nChar < 0x20) type = PES_ALL; // always allow control chars else if (IsCharAlphaNumeric((TCHAR)nChar) && !IsCharAlpha((TCHAR)nChar)) type = PES_NUMBERS; else if (IsCharAlpha((TCHAR)nChar)) type = PES_LETTERS; else type = PES_OTHERCHARS; if (m_wParseStyle & type) { CEdit::OnChar(nChar, nRepCnt, nFlags); // permitted } else { // illegal character - inform parent OnBadInput(); } }