Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "lSEdit.h"
- #include "lSColors.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- BEGIN_MESSAGE_MAP(ClSEdit, CEdit)
- //{{AFX_MSG_MAP(ClSEdit)
- ON_WM_MOUSEMOVE()
- ON_WM_PAINT()
- ON_WM_SETFOCUS()
- ON_WM_KILLFOCUS()
- ON_WM_SYSCOLORCHANGE()
- ON_WM_VSCROLL()
- ON_WM_HSCROLL()
- ON_WM_CTLCOLOR()
- // do not remove
- ON_WM_STYLECHANGING()
- //ON_CONTROL_REFLECT_EX(EN_UPDATE, OnEnUpdate)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- ClSEdit::ClSEdit()
- {
- CWinApp *pMainApplication;
- pMainApplication = AfxGetApp ();
- m_hInstance = pMainApplication->m_hInstance;
- m_bVScrollPressed = TRUE;
- m_bHScrollPressed = TRUE;
- m_bIsActivateSound = FALSE;
- m_bIsHScrollSound = FALSE;
- m_bIsVScrollSound = FALSE;
- m_bMouseOnEdit = FALSE;
- m_bIsFocused = FALSE;
- m_iHorizontalScrollWidth = NULL;
- m_iVerticalScrollWidthLeft = NULL;
- m_iVerticalScrollWidthRight = NULL;
- m_bHorizontalFrameWidth = NULL;
- m_bVerticalFrameWidth = NULL;
- GetSysColors ();
- }
- ClSEdit::~ClSEdit(){}
- void ClSEdit::OnMouseMove(UINT nFlags, CPoint point)
- {
- CEdit::OnMouseMove(nFlags, point);
- if (m_bIsFocused) return;
- if (GetCapture() != this)
- {
- m_bMouseOnEdit = TRUE;
- SetCapture();
- DrawEdit();
- // Play sound
- if (m_bIsActivateSound)
- {
- ::PlaySound ((LPCTSTR)m_StrActivateSound, m_hInstance, SND_ASYNC | SND_RESOURCE);
- }
- }
- else
- {
- CRect RectEditControl;
- GetClientRect(&RectEditControl);
- if (!RectEditControl.PtInRect(point))
- {
- m_bMouseOnEdit = FALSE;
- DrawEdit();
- ReleaseCapture();
- }
- }
- }
- void ClSEdit::OnPaint()
- {
- // Process default (do not remove)
- Default();
- // Process control drawing (main!)
- DrawEdit();
- }
- BOOL ClSEdit::DrawEdit(VOID)
- {
- CPaintDC dc(this);
- CRect RectEditControl;
- GetClientRect(&RectEditControl);
- CDC *pEditControlDC;
- pEditControlDC = GetDC();
- RectEditControl.top -= m_bHorizontalFrameWidth;
- RectEditControl.bottom += m_iHorizontalScrollWidth;
- RectEditControl.bottom += m_bHorizontalFrameWidth;
- RectEditControl.right += m_iVerticalScrollWidthRight;
- RectEditControl.right += m_bVerticalFrameWidth;
- RectEditControl.left -= m_iVerticalScrollWidthLeft;
- RectEditControl.left -= m_bVerticalFrameWidth;
- pEditControlDC->SetBkMode(OPAQUE);
- pEditControlDC->SetBkColor(TRANSPARENT);
- pEditControlDC->FillSolidRect(&RectEditControl, COLOR_BLACK);
- if (m_bMouseOnEdit)
- {
- // Mouse on edit
- pEditControlDC->Draw3dRect(&RectEditControl, m_clrShadow, m_clrHiLite);
- RectEditControl.DeflateRect(1,1);
- pEditControlDC->Draw3dRect(&RectEditControl, m_clrDarkShadow, m_clrButton);
- }
- else
- {
- // Mouse is not on edit
- pEditControlDC->Draw3dRect(&RectEditControl, m_clrHiLite, m_clrHiLite);
- RectEditControl.DeflateRect(1,1);
- pEditControlDC->Draw3dRect(&RectEditControl, m_clrHiLite, m_clrHiLite);
- }
- CString str;
- pEditControlDC->SelectObject(GetFont());
- GetWindowText(str);
- pEditControlDC->SetTextColor(COLOR_WHITE);
- //pEditControlDC->SetBkColor(RGB(0, 0, 0));
- GetRect(&RectEditControl);
- int winStyle = GetStyle();
- int style;
- if (winStyle & ES_CENTER)
- style = DT_CENTER;
- else if (winStyle & ES_RIGHT)
- style = DT_RIGHT;
- else
- style = DT_LEFT;
- if (winStyle & ES_PASSWORD)
- {
- style = style |= ES_PASSWORD;
- TRACE(_T("IS %s\n"), "PASSWORD");
- //SetPasswordChar('*');
- }
- pEditControlDC->DrawText(str, &RectEditControl, style);
- UpdateData();
- // Release DC ! do not remove!
- ReleaseDC (pEditControlDC);
- //Invalidate(TRUE);
- return (TRUE);
- }
- BOOL ClSEdit::OnDrawItemValue(CDC& dc, CRect rcValue)
- {
- CString str;
- GetWindowText(str);
- CString strPassword = {'*' * str.GetLength()};
- dc.DrawText( strPassword, rcValue, DT_SINGLELINE|DT_VCENTER);
- return TRUE;
- }
- HBRUSH ClSEdit::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- //HBRUSH hbr = CEdit::OnCtlColor(pDC, pWnd, nCtlColor);
- //pDC->SetBkMode(TRANSPARENT);
- //pDC->SetTextColor(RGB(255, 0, 0));
- //return hbr;
- TRACE(_T("IS %s\n"), nCtlColor);
- pDC->SetBkMode(TRANSPARENT);
- return (HBRUSH)::GetStockObject(NULL_BRUSH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement