Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > Static. Установка Стиля и цвета текста


Автор: devmstr 15.4.2005, 07:44
Как сделать программно менять цвет и стиль(например сделать подчеркнутым) текст в Static.
Заранеее спасибо.

Автор: _hunter 15.4.2005, 15:09
э... это шутка, да?
свойство Font тебе что-то говорит?

Автор: Дрон 17.4.2005, 11:07
_hunter
Какое свойство Font ? smile

magician
Я давно этим не занимался, но вроде есть сообщение WM_SETFONT

Цитата
To send this message, call the SendMessage function as follows.

lResult = SendMessage(      // returns LRESULT in lResult   
(HWND) hWndControl,      // handle to destination control   
(UINT) WM_SETFONT,      // message ID
(WPARAM) wParam,      // = (WPARAM) () wParam;   
(LPARAM) lParam      // = (LPARAM) () lParam; ); 

Parameters
wParam
Handle to the font. If this parameter is NULL, the control uses the default system font to draw text.
lParam
The low-order word of lParam specifies whether the control should be redrawn immediately upon setting the font. If this parameter is TRUE, the control redraws itself.

Return Value
This message does not return a value.


А вот задавать цвета можно обработав сообщение WM_CTLCOLORSTATIC
Цитата
A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control.

A window receives this message through its WindowProc function.

Syntax
WM_CTLCOLORSTATIC

    WPARAM wParam
    LPARAM lParam;
   
Parameters
wParam
Handle to the device context for the static control window.
lParam
Handle to the static control.

Return Value
If an application processes this message, the return value is a handle to a brush that the system uses to paint the background of the static control.

Remarks
...
The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.
...

Автор: devmstr 18.4.2005, 09:50
Дрон
Огромное спасибо! Вы мне очень помогли!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)