Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CEdit Controle - Disabled texte color

32 views
Skip to first unread message

Fulcanel

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to

I created a ActiveX controle which subclass CEdit.

I can't changed texte color when controle is disabled.
I use the method described in MFC :

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

ON_MESSAGE(OCM_CTLCOLOREDIT, OnOcmCtlColorEdit)
ON_MESSAGE(OCM_CTLCOLORSTATIC, OnOcmCtlColorStatic)
...

/*--------------------------------------------------------------------------
------------
----------------------------------------------------------------------------
------------*/
LRESULT CCtEditBoxCtrl::OnOcmCtlColorEdit(WPARAM wParam, LPARAM lParam)
{
if (m_pBackBrush == NULL)
m_pBackBrush = new CBrush(RGB(0,0,0));

CDC* pdc = CDC::FromHandle((HDC)wParam);
pdc->SetBkMode(TRANSPARENT);

pdc->SetBkColor(m_enabledBackColor);
pdc->SetTextColor(m_enabledForeColor);

HBRUSH far* hbr = (HBRUSH far*)m_pBackBrush->GetSafeHandle();
return ((DWORD)hbr);
}

/*--------------------------------------------------------------------------
------------
----------------------------------------------------------------------------
------------*/
LRESULT CCtEditBoxCtrl::OnOcmCtlColorEdit(WPARAM wParam, LPARAM lParam)
{
if (m_pBackBrush == NULL)
m_pBackBrush = new CBrush(RGB(0,0,0));

CDC* pdc = CDC::FromHandle((HDC)wParam);
pdc->SetBkMode(TRANSPARENT);

pdc->SetBkColor(m_enabledBackColor);
pdc->SetTextColor(m_enabledForeColor);

HBRUSH far* hbr = (HBRUSH far*)m_pBackBrush->GetSafeHandle();
return ((DWORD)hbr);
}

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

Every thing works fine when Controle is enabled,
but when it is disabled back color change, but texte
color stay grey.

Which is the color obtained with "GetSysColor(COLOR_GRAYTEXT)"
I think ...

I don't understand why I can't change this color in my controle.
Can anyone help ?


Andreas Borchard

unread,
Nov 24, 2000, 3:00:00 AM11/24/00
to

Fulcanel wrote:

Hello Fulcanel!

You have to overwrite OnEraseBackground(), too...

ciao
Andreas


Fulcanel

unread,
Nov 24, 2000, 3:00:00 AM11/24/00
to

> > Every thing works fine when Controle is enabled,
> > but when it is disabled back color change, but texte
> > color stay grey.
> >
> > Which is the color obtained with "GetSysColor(COLOR_GRAYTEXT)"
> > I think ...
> >
> > I don't understand why I can't change this color in my controle.
> > Can anyone help ?
>
> Hello Fulcanel!
>
> You have to overwrite OnEraseBackground(), too...

Well, ok but what should I do in "OnEraseBackground" ?
I don't want to change background color, but foreground (text) color...

Andreas Borchard

unread,
Nov 27, 2000, 3:00:00 AM11/27/00
to
Hi Fulcanel!

Instead of disabling the edit control call "myEdit->SetReadOnly(TRUE)" !
-> If an edit control is disabled "OnCtlColor" is not called!


0 new messages