// CusEdit.cpp : implementation file // #include "stdafx.h" #include "effectEditor.h" #include "CusEdit.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCusEdit CCusEdit::CCusEdit() { m_br = NULL; } CCusEdit::~CCusEdit() { if(m_br) DeleteObject(m_br); } BEGIN_MESSAGE_MAP(CCusEdit, CEdit) //{{AFX_MSG_MAP(CCusEdit) ON_WM_CTLCOLOR_REFLECT() ON_WM_SETFOCUS() ON_WM_KILLFOCUS() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCusEdit message handlers HBRUSH CCusEdit::CtlColor(CDC* pDC, UINT nCtlColor) { if(m_bEnableBkColor) { pDC->SetBkColor(m_BkABGR); pDC->SetTextColor(m_TextABGR); return m_br; } return NULL; } void CCusEdit::OnSetFocus(CWnd* pOldWnd) { CEdit::OnSetFocus(pOldWnd); // TODO: Add your message handler code here Invalidate(); } void CCusEdit::OnKillFocus(CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); // TODO: Add your message handler code here Invalidate(); } void CCusEdit::SetBkColor(COLORREF BkABGR, COLORREF TextABGR) { if(m_br) DeleteObject(m_br); m_br = CreateSolidBrush(BkABGR); m_BkABGR = BkABGR; m_TextABGR = TextABGR; m_bEnableBkColor = TRUE; } void CCusEdit::DisableBkColor(void) { m_bEnableBkColor = FALSE; } void CCusEdit::SetValue(float fValue) { char strChar[256]; sprintf(strChar, "%f", fValue); SetWindowText(strChar); } void CCusEdit::SetValue(unsigned char cValue) { char strChar[256]; sprintf(strChar, "%d", cValue); SetWindowText(strChar); } void CCusEdit::SetValue(unsigned long dwValue) { char strChar[256]; sprintf(strChar, "%u", dwValue); SetWindowText(strChar); } CCusEdit::operator float(void) const { CString strValue; GetWindowText(strValue); return (float)atof(strValue.GetBuffer(0)); } CCusEdit::operator unsigned char(void) const { CString strValue; GetWindowText(strValue); return (unsigned char)atof(strValue.GetBuffer(0)); } CCusEdit::operator unsigned long(void) const { CString strValue; GetWindowText(strValue); return (unsigned long)atof(strValue.GetBuffer(0)); } CCusEdit::operator const char *(void) const { CString strValue; GetWindowText(strValue); return (const char *)strValue; } void CCusEdit::operator=(float const &rhs) { char strChar[256]; sprintf(strChar, "%f", rhs); SetWindowText(strChar); } void CCusEdit::operator=(unsigned char const &rhs) { char strChar[256]; sprintf(strChar, "%d", rhs); SetWindowText(strChar); }