22 #define SHIFTED 0x8000 28 m_TextColor = ::GetSysColor (COLOR_WINDOWTEXT);
29 m_BackColor = ::GetSysColor (COLOR_WINDOW);
30 m_FocusedBackColor = m_BackColor;
34 m_FocusedBackBrush = NULL;
35 m_bFloatingPointMode =
false;
38 m_bMsgHandled = FALSE;
43 ATLASSERT(m_hWnd == NULL);
60 CWindowImpl<CEditPlus, CEdit>::SubclassWindow(hWnd);
103 if (m_BackColor != value)
150 return(m_FocusedBackColor);
165 if (m_FocusedBackColor != value)
167 m_FocusedBackColor = value;
183 return(m_FocusedTextColor);
198 m_FocusedTextColor = value;
211 return(m_bFloatingPointMode);
226 m_bFloatingPointMode = value;
242 return(m_bNotifyOnCR);
255 m_bNotifyOnCR = value;
264 void CEditPlus::UpdateBackBrushes()
269 m_BackBrush = ::CreateSolidBrush (m_BackColor);
271 m_FocusedBackBrush = ::CreateSolidBrush(m_FocusedBackColor);
275 void CEditPlus::DeleteBrushes()
278 if (m_BackBrush != NULL)
280 ::DeleteObject (m_BackBrush);
284 if (m_FocusedBackBrush != NULL)
286 ::DeleteObject(m_FocusedBackBrush);
287 m_FocusedBackBrush = NULL;
297 BOOL CEditPlus::OnEraseBkgnd(CDCHandle dc)
302 LRESULT CEditPlus::OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
305 HWND hWnd = (HWND)lParam;
312 HDC dc = (HDC)wParam;
313 ::SetBkMode(dc, OPAQUE);
315 if (GetFocus() != m_hWnd)
319 ::SetBkColor(dc, m_BackColor);
321 return((
long)m_BackBrush);
326 ::SetBkColor(dc, m_FocusedBackColor);
328 return((
long)m_FocusedBackBrush);
338 void CEditPlus::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
341 if (nChar == VK_RETURN)
343 if (m_bNotifyOnCR ==
true)
346 ((WPARAM) m_hWnd), ((LPARAM)0));
349 SetMsgHandled(FALSE);
355 if (m_bFloatingPointMode ==
true)
359 SetMsgHandled(FALSE);
364 ::GetCaretPos (&caret);
365 caret.x = LOWORD (CharFromPos (caret));
368 int chars = ::GetWindowTextLength(m_hWnd);
369 LPTSTR lp = text.GetBufferSetLength(chars + 1);
370 GetWindowText( lp, chars + 1);
371 text.SetAt(chars, _T(
'\0'));
372 text.ReleaseBuffer();
377 SetMsgHandled(FALSE);
380 else if (nChar == ((TCHAR)
'-'))
384 if (((text.GetLength() > 0) && (text[0]!= ((TCHAR)
'-'))) || (text.GetLength()==0))
385 SetMsgHandled(FALSE);
389 if (text.GetLength() >= 2)
392 TCHAR previous_char = (TCHAR)text[caret.x - 1];
394 if (previous_char ==((TCHAR)
'E'))
395 SetMsgHandled(FALSE);
399 else if (nChar == ((TCHAR)
'E'))
401 if ((caret.x == 1) && (text[0] == ((TCHAR)
'-')))
406 for (
int i=0; i<text.GetLength(); i++)
408 if (text[i] == ((TCHAR)
'E'))
412 SetMsgHandled(FALSE);
415 else if (nChar == ((TCHAR)
'.'))
417 for (
int i=0; i<text.GetLength(); i++)
419 if (text[i] == ((TCHAR)
'.'))
423 for (
int i=0; i<text.GetLength(); i++)
425 if ((text[i]==((TCHAR)
'E')) && (caret.x > i))
429 SetMsgHandled(FALSE);
434 SetMsgHandled(FALSE);
void EnableFloatingPointMode(bool enabled)
Change the Floating Point Mode state.
COLORREF GetFocusedBackColor() const
Default: COLOR_WINDOW.
const int WM_EDITP_EDIT_END
void UnSubclassEdit()
Un-subclass the window and release GDI resources.
void SetFocusedTextColor(COLORREF value)
Select a new text color used when the control has focus.
void SetTextColor(COLORREF value)
Select a new text color used when the control does not have focus.
bool IsNotifyOnCREnabled() const
Default: true.
void SetFocusedBackColor(COLORREF value)
Select a new background color used when the control has focus.
void EnableNotifyOnCR(bool value)
Change the 'Notify on CR' state.
COLORREF GetBackColor() const
Default: COLOR_WINDOW.
COLORREF GetTextColor() const
Default: COLOR_WINDOWTEXT.
void SetBackColor(COLORREF value)
Select a new background color used when the control does not have focus.
void SubclassEdit(HWND hWnd)
Subclass an edit control and create GDI objects.
bool IsFloatingPointModeEnabled() const
Default: false.
COLORREF GetFocusedTextColor() const
Default: CLR_RED.