void CColoredButton::OnLButtonDown(UINT nFlags, CPoint point) { SetOverButtonInfo( point); if( m_bMixedColor) m_iColorIndex = -1; if( m_iColorIndex != -1) { CRect rectWindow; GetWindowRect( &rectWindow); theApp.m_cttToolTips.ManualOn( rectWindow.left, rectWindow.bottom, &::GetToolTipText, this); m_ptCenter.x = ::GetSystemMetrics(SM_CXSCREEN)/2; m_ptCenter.y = ::GetSystemMetrics(SM_CYSCREEN)/2; GetCursorPos( &m_ptStarting); _bMouseMoveEnabled = TRUE; _bColorChanging = TRUE; if( !_bCursorHidden) { // hide mouse while (ShowCursor(FALSE)>=0); _bCursorHidden = TRUE; } SetCursorPos(m_ptCenter.x, m_ptCenter.y); } CButton::OnLButtonDown(nFlags, point); }
void CColoredButton::OnMouseMove(UINT nFlags, CPoint point) { if( (m_iColorIndex != -1) && (nFlags & MK_LBUTTON) && _bMouseMoveEnabled) { SetOverButtonInfo( point); EnableToolTips( TRUE); theApp.m_cttToolTips.ManualUpdate(); CPoint ptCurrent; GetCursorPos( &ptCurrent); ColorToComponents(); SLONG slResult = m_ubComponents[ m_iColorIndex][m_iComponentIndex]; slResult += ptCurrent.x-m_ptCenter.x; slResult = Min(Max(slResult,0L), 255L); m_ubComponents[ m_iColorIndex][m_iComponentIndex] = UBYTE( slResult); COLOR colResult; if( m_iColorIndex == 0) { colResult = HSVToColor( m_ubComponents[0][0], m_ubComponents[0][1], m_ubComponents[0][2]); ColorToRGB(colResult, m_ubComponents[1][0], m_ubComponents[1][1], m_ubComponents[1][2]); } else { colResult = RGBToColor( m_ubComponents[1][0], m_ubComponents[1][1], m_ubComponents[1][2]); ColorToHSV(colResult, m_ubComponents[0][0], m_ubComponents[0][1], m_ubComponents[0][2]); } // add alpha colResult |= m_ubComponents[0][3]; m_colColor = colResult; m_colLastColor = colResult; m_bMixedColor = FALSE; Invalidate( FALSE); SendMessage( WM_PAINT); // invalidate parent dialog if( m_pwndParentDialog != NULL) m_pwndParentDialog->UpdateData( TRUE); if(ptCurrent != m_ptCenter) { SetCursorPos( m_ptCenter.x, m_ptCenter.y); } } CButton::OnMouseMove(nFlags, point); }
void CColoredButton::OnLButtonDown(UINT nFlags, CPoint point) { m_ptCenter.x = ::GetSystemMetrics(SM_CXSCREEN)/2; m_ptCenter.y = ::GetSystemMetrics(SM_CYSCREEN)/2; GetCursorPos( &m_ptStarting); SetOverButtonInfo( point); if( m_bMixedColor) m_iColorIndex = -1; if( m_iColorIndex != -1) { _bMouseMoveEnabled = TRUE; ShowCursor(FALSE); SetCursorPos(m_ptCenter.x, m_ptCenter.y); } CButton::OnLButtonDown(nFlags, point); }