void CSkinBtn::DrawItem(LPDRAWITEMSTRUCT lpDIS) { //// TODO: 添加您的代码以绘制指定项 //CDC* pDC = CDC::FromHandle(lpDIS->hDC); UINT state = lpDIS->itemState; //CRect rect; //rect.CopyRect(&lpDIS->rcItem); m_state = NORMAL; if (state & ODS_FOCUS) { if (state & ODS_SELECTED) { m_state = DOWN; } else { if(m_bMouseOver) m_state = HOVER; } } else { m_state = NORMAL; } if (state & ODS_DISABLED) { m_state = DISABLE; m_bEnabled = false; } switch(m_bDrawScroll) { case BUTTON_SCROLL: DrawButtonScroll(); break; case BUTTON_TITLE: DrawButtonTitle(); break; case BUTTON_NOPICTURE: DrawButtonNullPicture(); break; default: DrawButton(); break; } }
void CDreamSkinTab::DrawButton(HDC hDC, RECT rcItem, int nIndex) { int nStatus = DRAWSTATUS_NORMAL; if (nIndex == m_nCurSel) nStatus = DRAWSTATUS_PRESS; else if (nIndex == m_nCurHover) nStatus = DRAWSTATUS_HOVER; DrawButtonBorder(hDC, rcItem, nStatus); RECT rcClient = GetButtonRectClient(rcItem, nStatus); DrawButtonBackground(hDC, rcClient, nStatus); DrawButtonTitle(hDC, rcClient, nIndex, nStatus); }
void CSkinBtn::SetColor(COLORREF fgcolor,COLORREF bgcolor) { m_fg = fgcolor; m_bg = bgcolor; switch(m_bDrawScroll) { case BUTTON_SCROLL: DrawButtonScroll(); break; case BUTTON_TITLE: DrawButtonTitle(); break; case BUTTON_NOPICTURE: DrawButtonNullPicture(); break; default: DrawButton(); break; } }
void CSkinBtn::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 //if (nFlags & MK_LBUTTON && m_bMouseOver == FALSE) // return; if(!m_bMouseOver&&m_bEnabled) { m_bMouseOver=true; m_state = HOVER; CPoint point; CRect rect; GetWindowRect(&rect); GetCursorPos(&point); if (!rect.PtInRect(point) && m_bMouseOver&&m_bEnabled) { SetTimer(1,10,NULL); return; } switch(m_bDrawScroll) { case BUTTON_SCROLL: DrawButtonScroll(); break; case BUTTON_TITLE: DrawButtonTitle(); break; case BUTTON_NOPICTURE: DrawButtonNullPicture(); break; default: DrawButton(); break; } SetTimer(1,10,NULL); } CButton::OnMouseMove(nFlags, point); }
void CSkinBtn::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CPoint point; CRect rect; GetWindowRect(&rect); GetCursorPos(&point); switch(nIDEvent) { case(1): { if (!rect.PtInRect(point) && m_bMouseOver&&m_bEnabled) { KillTimer (1); m_bMouseOver=false; m_state = NORMAL; switch(m_bDrawScroll) { case BUTTON_SCROLL: DrawButtonScroll(); break; case BUTTON_TITLE: DrawButtonTitle(); break; case BUTTON_NOPICTURE: DrawButtonNullPicture(); break; default: DrawButton(); break; } } } break; case(2): { //发送消息给PARENT窗口 m_SendTime++; if(m_SendTime == 1) { ::SendMessage(m_ParentWnd,WM_BUTTON_FIRST_SELECT,point.x,point.y); // ::SendMessage(m_ParentWnd,WM_BUTTON_SELECT,point.x,point.y); } } break; case(101): this->Invalidate(FALSE); break; default: break; } if(m_state!=DOWN) { KillTimer (2); m_SendTime = 0; // ::SendMessage(m_ParentWnd,WM_BUTTON_FIRST_SELECT,NULL,m_SendTime); } CButton::OnTimer(nIDEvent); }