怎样改变编辑框中的字体颜色????

zyqwk2003 2003-08-22 10:50:43
我在对话框中设置了一个编辑框和几个按钮,如何实现点击不同的按钮,编辑框中的字显示不同的颜色。
...全文
169 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouyong0371 2003-08-22
  • 打赏
  • 举报
回复
头文件:
COLORREF m_Color;
.cpp:

void CSetEditColorDlg::OnRed()
{
// TODO: Add your control notification handler code here
m_Color = RGB(255, 0, 0);
Invalidate();
}

void CSetEditColorDlg::OnGreen()
{
// TODO: Add your control notification handler code here
m_Color = RGB(0, 255, 0);
Invalidate();

}

void CSetEditColorDlg::OnBlue()
{
// TODO: Add your control notification handler code here
m_Color = RGB(0, 0, 255);
Invalidate();

}

HBRUSH CSetEditColorDlg::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_EDIT)
SetTextColor(pDC->m_hDC, m_Color);

// TODO: Return a different brush if the default is not desired
return hbr;
}

最好在程序初始化时就给m_Color一个初值

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧