CDecimalSupport.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * CDecimalSupport.cpp
  3. * -------------------
  4. * Purpose: Various extensions of the CDecimalSupport implementation.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #include "stdafx.h"
  10. #include "Snd_defs.h"
  11. #include "CDecimalSupport.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. BEGIN_MESSAGE_MAP(CNumberEdit, CEdit)
  14. ON_WM_CHAR()
  15. ON_MESSAGE(WM_PASTE, &CNumberEdit::OnPaste)
  16. END_MESSAGE_MAP()
  17. void CNumberEdit::SetTempoValue(const TEMPO &t)
  18. {
  19. SetFixedValue(t.ToDouble(), 4);
  20. }
  21. TEMPO CNumberEdit::GetTempoValue()
  22. {
  23. double d;
  24. GetDecimalValue(d);
  25. return TEMPO(d);
  26. }
  27. void CNumberEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  28. {
  29. BOOL bHandled = false;
  30. CDecimalSupport<CNumberEdit>::OnChar(0, nChar, 0, bHandled);
  31. if(!bHandled) CEdit::OnChar(nChar , nRepCnt, nFlags);
  32. }
  33. LPARAM CNumberEdit::OnPaste(WPARAM wParam, LPARAM lParam)
  34. {
  35. bool bHandled = false;
  36. CDecimalSupport<CNumberEdit>::OnPaste(0, wParam, lParam, bHandled);
  37. if(!bHandled)
  38. return CEdit::DefWindowProc(WM_PASTE, wParam, lParam);
  39. else
  40. return 0;
  41. }
  42. OPENMPT_NAMESPACE_END