编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

diffcult problem.who can answer it?

diffcult problem.who can answer it?

Visual C++6.0 environment.
Use API function.
There is a edit box.its id is EDIT1,its hwnd is hedit.
When you type character in the edit box .the color of the character is red.
How to do?

TOP

CEdit *pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
CDC *pDC = pEdit->GetDC();
pDC->SetTextColor(RGB(255,0,0));
CString str;
GetDlgItemText(IDC_EDIT1,str);
CRect rect;
pEdit->GetClientRect(&rect);
pDC->DrawText(str,&rect,DT_SINGLELINE);
pEdit->ReleaseDC(pDC);

TOP

上面的不对 这样才好 HBRUSH CDdDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(nCtlColor == CTLCOLOR_EDIT) { if(pWnd->GetDlgCtrlID() == IDC_EDIT1) { pDC->SetTextColor(RGB(255,0,0));//改变字体颜色 } } return hbr; }

TOP

发新话题