📄 color_in_disabled_combo.shtml.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>Miscellaneous - Showing disabled combo text in black</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed">
<table WIDTH="100%">
<tr WIDTH="100%">
<td><A HREF="http://209.66.99.126/cgi/ads.cgi?advert=genitor"><IMG SRC="../banners/genitor.gif" tppabs="http://www.codeguru.com/banners/genitor.gif" HEIGHT=60 WIDTH=468 ALT="Genitor - award-winning Object Construction Suite for C/C++ development, documentation, and maintainance" BORDER=2></A><BR><SMALL><A HREF="http://209.66.99.126/cgi/ads.cgi?advert=genitor">Click here to get a trail copy of Genitor V3.1</A></SMALL><td>
</tr>
</table>
<CENTER>
<H3>
<FONT COLOR="#AOAO99">Showing disabled combo text in black</FONT></H3></CENTER>
<CENTER>
<H3>
<HR></H3></CENTER>
This article was contributed by <A HREF="mailto:stolar@phasecom.co.il">Moshe Stolar</A>.
This is only half a solution - works only with CBS_DROPDOWN but not with CBS_DROPDOWNLIST.
If you can find a solution for CBS_DROPDOWNLIST, please let him know (and copy me).
<p>I hope that the picture I am hereby attaching speaks for itself: the
IP-address in Fig.2 is easily readable, while the parameters in Fig.1
are not.
<p><img src="color_in_disabled_combo.jpg" tppabs="http://www.codeguru.com/misc/color_in_disabled_combo.jpg"></p>
<p>The same problem is encountered in Windows' Find File, the one that you
run from the Start button menu. While it performs the search, the
search pattern is dimmed.
<p>IDC_COMBO is a combo control of a dialog box. The code that follows is placed in the
dialog's OnInitDialog handler, here it is:
<PRE><TT><FONT COLOR="#990000"> // Make the disabled combo's edit control appear as enabled & R/O
// 1. The first child window of a combo is its edit control
CEdit* pComboEdit=(CEdit*)(GetDlgItem( IDC_COMBO )->GetWindow(GW_CHILD ));
// 2. Enable combo's edit control, not the combo itself, and set R/O
pComboEdit->EnableWindow( TRUE );
pComboEdit->SetReadOnly();
</FONT></TT></PRE>
<p>However, this approach does not work when the combo box is of the
DropList type, since such a combo consists of two windows only, the
combo itself and the combo list control, and, therefore, I can't enable
it.
<p>And also, overriding the OnCtlControl handler in order to change colors
doesn't help - there is no problem to change the text background color,
but the text color still appears dimmed.
<P>
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="../index.htm" tppabs="http://www.codeguru.com/">Goto HomePage</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© 1997 Zafir Anjum</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
<CENTER><IMG SRC="../cgi/Count.cgi-ft=2&dd=E-df=misc_color_in_disabled_combo.cnt" tppabs="http://www.codeguru.com/cgi/Count.cgi?ft=2&dd=E%7cdf=misc_color_in_disabled_combo.cnt" ALIGN="BOTTOM" BORDER="0"></CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -