Cambiar fuentes y color

23/09/2004 - 12:46 por sadasd | Informe spam
Quisiera saber cual es la funcion para cambiar el estilo de texto,el tamaño
y el color de un edit box.

Gracias
 

Leer las respuestas

#1 Rodrigo Corral [MVP]
27/09/2004 - 10:31 | Informe spam
Este ejemplo muestra como cambiar el color de la fuente y el del fondo del
control, una técnica similar se seguiria para cambiar la fuente, en lugar de
pinceles, crea fuentes (CFont), y asignalas al control.

BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_WM_CTLCOLOR()
END_MESSAGE_MAP()

COLORREF m_ForeColor;
COLORREF m_BackColor ;
CBrush m_brBkgnd;

en el constructor del dialogo

{
...
m_BackColor = RGB(255, 255, 0);
m_ForeColor = RGB(0, 255, 255);
m_brBkgnd.CreateSolidBrush( m_BackColor) ;
...
}

HBRUSH CMyDialog::CtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{

HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
UINT nIDD = pWnd->GetDlgCtrlID();
switch ( nIDD )
{
case IDC_MY_EDIT:
pDC->SetTextColor( m_ForeColor );
pDC->SetBkColor( m_BackColor );

default:
break;
}

return hbr;

}

Otro ejemplo, que usa herencia, para cambiar todos los textbox y no solo
algunos
How To Change the Color of an MFC Child Control Class
http://support.microsoft.com/defaul...-us;132080


Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Preguntas similares