<!-- Link to source file download -->
Download source files - 1 Kb
<!-- Article image -->
This is a very quick fix to displaying a disabled combo
box as read only. If you have a form with lots of read only edit boxes, the normal
disabled combo box looks a bit funny. Read only edit boxes have black text with grey
backgrounds. While disabled combo boxes have dark grey text with grey backgrounds.
Hard to explain to users.
This code only works for drop down style combo boxes. This is because I am
setting the child edit box as enabled and read only when the parent combo box is
When the combo box gets a
WM_ENABLE message, check the bEnable
flag and call
SetReadOnly for the edit box.
A pointer to the edit box is retrieved by just getting the first child window of the
void CReadOnlyComboBox::OnEnable(BOOL bEnable)
CEdit* pEdit = (CEdit*)GetWindow(GW_CHILD);
The only down side to this approach is the text can't be selected with the mouse
like a read only edit box.