Thomas Stockbruegger
asked on
Need some help with mouse over, change color
Hello,
I would like to change the color of a static text (like a hyperlink) when I go with my mouse over the
text.
I already change the cursor to a hand-cursor when my mouse is over the static text.
Please let me know. 500 points
Best regards,
Thomas
I would like to change the color of a static text (like a hyperlink) when I go with my mouse over the
text.
I already change the cursor to a hand-cursor when my mouse is over the static text.
Please let me know. 500 points
Best regards,
Thomas
BOOL COffenePostenDialog_Detail::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
BOOL bReturn;
CRect rcBtn;
CRect rcBtn1;
CRect rcBtn2;
CPoint ptCursor;
CPoint ptCursor1;
CPoint ptCursor2;
// Calculate the current cursor position
// Change cursor if we are over Internet and Email link
//-----------------------------------
CWnd* pBtn = GetDlgItem(IDC_STATIC_INTERNET);
CWnd* pBtn1 = GetDlgItem(IDC_STATIC_EMAIL);
CWnd* pBtn2 = GetDlgItem(IDC_STATIC_TELEFON);
pBtn->GetWindowRect(rcBtn);
GetCursorPos(&ptCursor);
pBtn1->GetWindowRect(rcBtn1);
GetCursorPos(&ptCursor1);
pBtn2->GetWindowRect(rcBtn2);
GetCursorPos(&ptCursor1);
//===========================================================================
if(rcBtn.PtInRect(ptCursor)==TRUE ||rcBtn1.PtInRect(ptCursor1)==TRUE||rcBtn2.PtInRect(ptCursor1)==TRUE)
{
CWinApp* pApp = AfxGetApp();
HCURSOR my_new_cursor = pApp->LoadCursor(IDC_CURSOR2); // load new cursor
SetCursor(my_new_cursor);
bReturn = TRUE;
}
else
{
bReturn = CDialog::OnSetCursor(pWnd, nHitTest, message);// default cursor
}
return bReturn;
//===========================================================================
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
HBRUSH COffenePostenDialog_Detail::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//--------------------------- Link Color Internet/ Email ------------------------------
if((pWnd->GetDlgCtrlID()==IDC_STATIC_INTERNET) ||(pWnd->GetDlgCtrlID()==IDC_STATIC_EMAIL))
{
pDC->SetTextColor(clr_blue);
}
//---------------------------------------------------------------------------------
return hbr;
}
//###############################################################################
This article might also be useful http://www.sahirshah.com/cpp/mouseover/MouseOver.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. That was easy and the code I was looking for, thanks a lot
http://www.codeproject.com/KB/buttons/hoverbutton.aspx
NOTE: may be you need to change CHoverButton::OnMouseHover
void CHoverButton::OnMouseHover
to
LRESULT CHoverButton::OnMouseHover
and return 0 from it