Graying Text in Disabled Multiline Edit ControlsLast reviewed: July 23, 1997Article ID: Q108937 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYDisabling multiline edit controls prevents user input to the control, but does not make the text unavailable (gray or dim) in the edit control. However, single line edit controls, when disabled, make the text unavailable, as well as preventing user input. This is a design feature in Windows and is not a bug.
MORE INFORMATIONThe rationale behind this design feature is that the single line edit control is generally used in different circumstances than is the multiline edit control. The single line edit control is used in such situations as selecting a filename, where making the disabled text unavailable helps make the user interface clearer. Multiline edit controls are often used as read- only fields, and therefore need to be black when disabled. One way to make the text of a disabled multiline edit control unavailable is described below. Whenever a predefined control is about to draw itself, it sends its parent a WM_CTLCOLOR message. The parent can use this message to set the control's text and background colors. In the window procedure of the multiline edit control's parent window, process the WM_CTLCOLOR message as follows:
Sample Code
static HBRUS hBrush; case WM_INITDIALOG: hBrush = CreateSolidBrush (GetSysColor (COLOR_WINDOW)); break; case WM_CTLCOLOR: /* If the control is disabled, set the text color to gray and the * background color to the system window background color. */ hCtl = GetDlgItem (hDlg, IDC_MULTIEDIT ); enabled = IsWindowEnabled(hCtl) ; if ((!enabled) && (HIWORD(lParam) == CTLCOLOR_EDIT)) { SetTextColor(wParam, RGB(128,128,128) ); SetBkColor( wParam, GetSysColor (COLOR_WINDOW)); return ((HBRUSH) hBrush); } break; InvalidateRect (hCtl, NULL, TRUE); UpdateWindow (hCtl); |
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |