Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding color to textbox?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how do i make my text box a different color?
 
If you are using MFC, and your project is a CDialog based project add the code below AFTER the line
CDialog::OnPaint(); in OnPaint method of your CDialog derived class.

CRect rc;
CBrush brush;
COLORREF clr=RGB(0,125,130); //here you put the desired color

brush.CreateSolidBrush(clr);

CWnd* pWnd = GetDlgItem(IDC_EDIT1);
pWnd->GetClientRect(&rc);
CDC* pDC=pWnd->GetDC();
pDC->SetBkMode(OPAQUE);

pDC->FillRect(&rc,&brush);
InvalidateRect(&rc);

This code works for sure, I have tried it myself.
If you have another type of project tell me, and give more details about it.

Hope this is helpful, s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top