15,978
社区成员
发帖
与我相关
我的任务
分享
BOOL bChange = FALSE;
BOOL CXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_MOUSEMOVE == pMsg->message)
{
CRect rc;
GetDlgItem(IDC_STATIC_PICTURE)->GetWindowRect(rc);
CPoint pt(pMsg->pt);
if(rc.PtInRect(pt))
{
bChange = TRUE;
}
else
{
bChange = FALSE;
}
GetDlgItem(IDC_STATIC_TEXT)->Invalidate(TRUE);
}
return CDialog::PreTranslateMessage(pMsg);
}
HBRUSH CXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if((CTLCOLOR_STATIC == nCtlColor) && (IDC_STATIC_TEXT == pWnd->GetDlgCtrlID()))
{
if(bChange)
{
pDC->SetTextColor(RGB(255, 0, 128));
}
else
{
pDC->SetTextColor(RGB(0, 0, 0));
}
}
// TODO: Return a different brush if the default is not desired
return hbr;
}