I have a problem with changing the background color in the title bar window. Is it possible to change with SDL2? Want to change from white color to black, like that
Asked
Active
Viewed 442 times
1 Answers
0
I don't think that's possible with just SDL2, but you can get the native window and use that.
Looking at your screenshot, I assume you are using Windows. You can get the HWND
like this (see this answer):
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
SDL_GetWindowWMInfo(window, &wmInfo);
HWND hwnd = wmInfo.info.win.window;
Once you have that, you'll want to set both the border color and the caption color (see this answer):
#include <dwmapi.h>
COLORREF titlebar_color = 0x0015171E;
DwmSetWindowAttribute(
hwnd, DWMWINDOWATTRIBUTE::DWMWA_BORDER_COLOR,
&titlebar_color, sizeof(titlebar_color)
);
DwmSetWindowAttribute(
hwnd, DWMWINDOWATTRIBUTE::DWMWA_CAPTION_COLOR,
&titlebar_color, sizeof(titlebar_color))
);
Of course, all of that only works on Windows (10 or later I think), and, as far as I understand, isn't even guaranteed to work. So you may want to error-check everything.
Another solution that isn't exactly what you ask for but is done entirely within SDL2 is to create a borderless window and draw your own title bar...

Nelfeal
- 12,593
- 1
- 20
- 39