主窗口上有一个文本框。
需要实现:
当鼠标位置在主窗口上时,文本框的字体颜色为默认的黑色
当鼠标的位置在CStatic上时,文本框的字体颜色为红色。
哪位能给出可行的代码
需要实现:
当鼠标位置在主窗口上时,文本框的字体颜色为默认的黑色
当鼠标的位置在CStatic上时,文本框的字体颜色为红色。
哪位能给出可行的代码
解决方案 »
- mfc怎么写按钮的消息响应函数,使其被单击时背景色改变,而其文本依然不发生改变?
- 如何用VC读取TXT文本
- 求《Visual C++教程》清华大学 丁有和电子版
- SetDialogBkColor在vc2005里没效果?
- CEdit的派生类动态改变字体颜色的问题
- 查找、比较、分析文件中的字符串及格式用什么方法好呢? 有没有案例参考一下呢?
- 基于OpenGL窗口上建立button切换全屏的问题!!!
- vc中最多可以动态分配多少内存空间?
- 对无线网卡信号强度提取的程序中的一点问题(附源码)
- 我New Dialog了一个,而后手动OnInitDialog,但是OnInitDialog却报错???(Release中,DEBUG不存在)
- 下面这个算法把RGB转换成什么空间了?
- 输入网址后提交的数据包,能否截获后修改再进行转发?
一点时间没有收到mousemove就把字体置为黑
主窗口上有一个文本框。
需要实现:
当鼠标位置在 主窗口 上时,CStatic 的字体颜色为默认的 黑色
当鼠标的位置在 CStatic 上时,CStatic 的字体颜色为 红色。
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message== WM_MOUSEMOVE)
{
CPoint pt=pMsg->pt;
CRect rc;
m_Haha.GetWindowRect(&rc);
// if(rc.PtInRect(pt))
{// in picture
if(!m_bRedStatic) m_Haha.Invalidate();
m_bRedStatic=TRUE;
afxDump << pt << "\n";
}
else
{
if(m_bRedStatic) m_Haha.Invalidate();
m_bRedStatic=FALSE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
//
HBRUSH CTest::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_STATIC)
{
if(m_bRedStatic)
{
pDC->SetTextColor(RGB(255,0,0));// bk of text
}
else
{
pDC->SetTextColor(RGB(0,0,0));// bk of text
}
return (HBRUSH)::GetStockObject(WHITE_BRUSH);//all
}
// TODO: Return a different brush if the default is not desired
return hbr;
}