Приведу вырезку из MSDN, если хочеш разберайся. ,
| Цитата | Coloring an Edit Control Each time an edit control is about to be painted to the screen, Windows sends the parent window a WM_CTLCOLOR message. The wParam parameter contains the handle to the display context of the edit control, the low-order word of the lParam parameter identifies the edit control, and the high-order word of lParam contains CTLCOLOR_EDIT. The application can set the color or pattern for the edit control by returning a handle to a brush. Brush handles can be obtained by selecting a stock object or by building a brush from a pattern bitmap. The application can also set the text foreground and background colors.
The following code sets the colors for an edit control to white text on a gray background. The colors for other controls use the defaults.
. . . case WM_CTLCOLOR: if ( HIWORD(lParam) == CTLCOLOR_EDIT ) { // Set the text background color. SetBkColor(wParam, RGB(128,128,128)); // Set the text foreground color. SetTextColor(wParam, RGB(255, 255, 255) ); // Return the control background brush. return GetStockObject(LTGRAY_BRUSH); } else return GetStockObject(WHITE_BRUSH); . . .
In Windows version 3.0, there is a bug that caused a single-line edit control to be colored incorrectly. Windows would draw the control with the colors and brush from a WM_CTLCOLOR message and then again with the standard colors. Here are two workarounds to this problem:
Create a multiple-line edit control instead of a single-line edit control. Use the following code instead of the code earlier in this section: . . . case WM_CTLCOLOR: if ( HIWORD(lParam) == CTLCOLOR_EDIT || HIWORD(lParam) == CTLCOLOR_MSGBOX ) { // Set the text background color. SetBkColor(wParam, RGB(128,128,128)); // Set the text foreground color. SetTextColor(wParam, RGB(255, 255, 255) ); // Return the control background brush. return GetStockObject(LTGRAY_BRUSH); } else return GetStockObject(WHITE_BRUSH); . . .
SetBkColor does not support dithered colors. This is not specific to edit controls, but the application developer needs to be aware of the situation when attempting to color edit controls. Windows uses the closest solid color for background color of a control. Thus both of the following statements produce a gray control background with a 16-color driver:
SetBkColor(wParam, RGB(64,128,128)); SetBkColor(wParam, RGB(128,128,128));
With a 256-color driver the first statement creates a gray/green background, and the second statement produces a gray background.
|
Таким образом в Memo можно сделать слово цветным. |