I've derived a Window from CWnd in which I create some OwnerDrawn Buttons. The Buttons are derived from CButton.
Now I want to change to BackgroundColor of my Buttons when the User is Hovering over it.
Therefore I already implemented that the OnMouseHover() and the OnMouseLeave() Messages are getting sent:
BEGIN_MESSAGE_MAP(CFooterButton, CButton)
ON_WM_MOUSEHOVER()
ON_WM_MOUSEMOVE()
ON_WM_MOUSELEAVE()
END_MESSAGE_MAP()
void CFooterButton::OnMouseMove(UINT nFlags, CPoint point)
{
//start tracking of Hover and Leave Event
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = m_hWnd;
tme.dwHoverTime = HOVER_DEFAULT;
TrackMouseEvent(&tme);
CButton::OnMouseMove(nFlags, point);
}
void CFooterButton::OnMouseHover(UINT nFlags, CPoint point)
{
HDC hdc = *GetWindowDC();
SetBkColor(hdc,RGB(54, 125, 184));
CButton::OnMouseHover(nFlags, point);
}
In the Debugger and Spy I can see that the code is getting called but nothing happens. Since I'm relatively new to MFC/c++ I assume I'm not using the DC correctly.. can someone explain me why it is not working and how i can fix it?