Hey there! first time posting. Currently we’ve tried using the non native title bar and while look wise we can get what we want, not having the windows snapping features is a bit of a no go. We’ve opted to use the native title bar (setUsingNativeTitleBar), but unfortunately the color for the titlebar is quite light, and our app is dark, so I just need to be able to change it to make it uniform to our app. can’t seem to find where this is changed.
Did you find a solution for this?
I found the same thing - to enable window snapping and prevent my standalone plugin window sometimes ending up halfway off the screen, it seems it’s required to use native title bar (I’ve only tested this in Windows)… that does mean you have to find another way to trigger the audio options (which I have done - now via a button in my editor).
My plugin is dark, the native title bar is white - at least in Windows 11 - so it’s not the best look.
I found this doing the trick when creating a colour picker which is DocumentWindow. In the constructor:
// other code....
setUsingNativeTitleBar(native);
setVisible(true);
auto hwnd = getPeer()->getNativeHandle();
COLORREF DARK_COLOR = 0x00505050;
auto result = DwmSetWindowAttribute((HWND)hwnd, DWMWINDOWATTRIBUTE::DWMWA_CAPTION_COLOR, &DARK_COLOR, sizeof(DARK_COLOR));
BOOL USE_DARK_MODE = true;
result = DwmSetWindowAttribute((HWND)hwnd, DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE, &USE_DARK_MODE, sizeof(USE_DARK_MODE));
It’s important to do these calls after the call to setUnsingNativeTitleBar as per my example, while it recreates the window. I don’t reaaly know if you need both these calls, perhaps only the last one, the call with DWMWA_USE_IMMERSIVE_DARK_MODE, is neccessary.
You need to #include “dwmapi.h”
And in the linker I had to add Dwmapi.lib to “Additional Dependencies”
More can be read here: c++ - Change the color of the title bar (caption) of a win32 application - Stack Overflow
And here’s the result
And w/o the extra calls:
HTH