TextOut VC++

stm8680568

использую данный метод для вывода текста рядом с нарисованным графиком. однако проблема в том, что буквы - большие, не те фонты и фон у них - белый! каким методом можно это отрегулировать?

maggi14

Используй класс CStatic

kokoc88

Эта функция использует какой-то цвет для отрисовки. Посмотри SetTextColor.

stm8680568

а как CStatic привязывается к координатам на картинке?
2: мне не цвет текста надо менять, а цвет фона, на котором он рисуется. у SetTextColor - один параметр, устанавливающий только цвет текста

maggi14

CDC::SelectObject
CFont, CFont::CreateFont
CBrush

maggi14

Так же, как и любой другой CWnd

kokoc88

Я не понял, тебе к чёрно-белому графику нужен бело-чёрный текст? Ну почитай хэлп к TextOut, там написано, какие цвета он использует для фона и текста.

stm8680568

график рисуется черным по серому. буквы черным по белому. получаются такие квадраты, в них буквы. в МСДН по CDC::TextOut про цвет ничего нет

maggi14

Блин, ну неужели сложно открыть МСДН?
int SetBkMode( int nBkMode );
Return Value
The previous background mode.
Parameters
nBkMode
Specifies the mode to be set. This parameter can be either of the following values:
OPAQUE Background is filled with the current background color before the text, hatched brush, or pen is drawn. This is the default background mode.
TRANSPARENT Background is not changed before drawing.
Remarks
Sets the background mode. The background mode defines whether the system removes existing background colors on the drawing surface before drawing text, hatched brushes, or any pen style that is not a solid line.

stm8680568

если знаешь, чего открывать - то просто а для меня неочевидно, например, из сотни методов CDC найти нужный

Bird_V

А в чём проблема? Раз фон неправильный - смотрим все методы, связынные с ним. Фон по-английски Background, часто сокращается до Bk, Bg. Запомнили. Теперь открывает статью CD, class members и вдумчиво смотрим на список групп методов

Color and Color Palette Functions Font Functions
Construction/Destruction Line-Output Functions
Coordinate Functions Path Functions
Data Members Clipping Functions
Device-Context Functions Ellipse and Polygon Functions
Drawing-Attribute Functions Printer Escape Functions
Drawing-Tool Functions Bitmap Functions
Initialization Simple Drawing Functions
Layout Functions Metafile Functions
Mapping Functions Scrolling Functions
Region Functions Text Functions
Type-Safe Selection. Helpers
В результате понимаем, что нам нужен раздел, выделенный зелёным .

Drawing-Attribute Functions

GetBkColor Retrieves the current background color.
GetBkMode Retrieves the background mode.
GetColorAdjustment Retrieves the color adjustment values for the device context.
GetDCBrushColor Retrieves the current brush color.
GetDCPenColor Retrieves the current pen color.
GetPolyFillMode Retrieves the current polygon-filling mode.
GetROP2 Retrieves the current drawing mode.
GetStretchBltMode Retrieves the current bitmap-stretching mode.
GetTextColor Retrieves the current text color.
SetBkColor Sets the current background color.
SetBkMode Sets the background mode.
SetColorAdjustment Sets the color adjustment values for the device context using the specified values.
SetDCBrushColor Sets the current brush color.
SetDCPenColor Sets the current pen color.
SetPolyFillMode Sets the polygon-filling mode.
SetROP2 Sets the current drawing mode.
SetStretchBltMode Sets the bitmap-stretching mode.
SetTextColor Sets the text color.

Вдумчивое разглядывание этого списка наводит на мысль, что неплохо бы прочитать выделенный опять таки зелёным раздел...
Оставить комментарий
Имя или ник:
Комментарий: