G
G
German2019-03-31 23:36:33
C++ / C#
German, 2019-03-31 23:36:33

[WinAPI] TextOut() color and window background color do not match, how to set the same color for both of them?

The problem is that text is displayed in the window and its background does not match the background of the window.
It looks like this:
5ca124cd49d90971871815.png
The color of the window itself looks like this:

...
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
...

I change the color of the text using this function:
SetBkColor(hdc, ...);
The second parameter is COLORREF , it can be obtained using the RGB() macro , but what is COLOR_WINDOW RGB ?
Tried to get it like this:
SetBkColor(hdc, RGB(
  GetRValue(GetSysColor(COLOR_WINDOW)),
  GetGValue(GetSysColor(COLOR_WINDOW)),
  GetBValue(GetSysColor(COLOR_WINDOW))
  ));

But the text remains completely white.
Of course, using Photoshop, I found out that this is 240;240;240, but that's not good enough.
What to do?
PS
These functions
GetRValue(GetSysColor(COLOR_WINDOW)),
GetGValue(GetSysColor(COLOR_WINDOW)),
GetBValue(GetSysColor(COLOR_WINDOW))

They output 255;255;255, and if you use COLOR_WINDOW - 1(which corresponds to COLOR_MENU) , then the answer is correct(240;240;240), why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2019-03-31
@SaNNy32

SetBkMode(hdc, TRANSPARENT) ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question