Disabled Text Color
Mark Koehler -- mkoehler@ix.netcom.com
Saturday, July 13, 1996
VC++ 4.1 Win95/WinNT 4.0
We've run across a problem in the application we are try to create. After
much fuss, it was decided the we don't want to have a disabled edit control
look the way it does when it is disabled. Under Win95 it is often very
difficult to READ disabled text against the disabled background. We'd like
our users to be able to read the contents of a control with enabling the
control.
Is there a straight forward way to change the disabled text color for a
series of controls within an application without affecting all applications
as SetSystemColor would do?
--
Mark Koehler
Atlanta, GA
MORIN Jean-Marc -- jmc21@planetb.fr
Wednesday, July 17, 1996
[Mini-digest: 3 responses]
Mark Koehler wrote:
>
> VC++ 4.1 Win95/WinNT 4.0
>
> We've run across a problem in the application we are try to create. After
> much fuss, it was decided the we don't want to have a disabled edit control
> look the way it does when it is disabled. Under Win95 it is often very
> difficult to READ disabled text against the disabled background. We'd like
> our users to be able to read the contents of a control with enabling the
> control.
>
> Is there a straight forward way to change the disabled text color for a
> series of controls within an application without affecting all applications
> as SetSystemColor would do?
> --
> Mark Koehler
> Atlanta, GA
Just implement function OnCtlColor into the parent Dialog or Window
and change the Brush....
This code look like this:
HBRUSH CSizeDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CPropPage::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetSafeHwnd() == ((CWnd*)GetDlgItem(IDC_EDIT2))->GetSafeHwnd())
{
if (!pWnd->IsWindowEnabled())
{
pDC->SetBkMode(OPAQUE);
pDC->SetBkColor(::GetSysColor(COLOR_BTNFACE));
pDC->SetTextColor(::GetSysColor(COLOR_BTNSHADOW));
}
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
This code do exactly the reverse of your need. I implement gray background
into my edit control (IDC_EDIT2) for any kind of plateform.
Just change color that you need in GetSysColor.
Enjoy reception
mjm
-----From: "Mike Blaszczak"
It seems like this kind of thing is exactly what WM_CTLCOLOR should be used
for. Use ClassWizard to write an OnCtlColor() handler for your dialog. Have
it change the colours as you like for the edit control in question. You need
to do this for each dialog you want to alter.
.B ekiM
-----From: "Ignacio Nicolбs Rodrнguez"
Hi!
If I guess right, what you are willing to have is a readonly edit control,
not a disabled one.
You can set the readonly style from the dialog-designer, or you can
SetWindowLong(GWL_STYLE, ES_READONLY).
By the way, welcome list-writers to Buenos Aires.
Ignacio Nicolбs Rodrнguez.
inz@cano.com.ar
Roger Onslow -- Roger_Onslow@compsys.com.au
Monday, July 22, 1996
>We've run across a problem in the application we are try to create. After
>much fuss, it was decided the we don't want to have a disabled edit control
>look the way it does when it is disabled. Under Win95 it is often very
>difficult to READ disabled text against the disabled background. We'd like
>our users to be able to read the contents of a control with enabling the
>control.
Have you tried making it read-only (rather than disable)?
/|\ Roger Onslow
____|_|.\ ============
_/.........\Senior Software Engineer
/CCC.SSS..A..\
/CC..SS...A.A..\ Computer
/.CC...SS..AAA...\ Systems
/\.CC....SSAA.AA../ Australia
\ \.CCCSSS.AA.AA_/
\ \...........// Ph: +61 49 577155
\ \...._____// Fax: +61 49 675554
\ \__|_/\_// RogerO@compsys.com.au
\/_/ \//
| Вернуться в корень Архива
|