Custom Window Border color using (dwmapi)

hi, I’m trying to fix a problem that I can’t find on google or on other platforms, I would like to change the color of the window borders in this case (red) using the api called ‘dwmapi’ I’ve tried many methods but I can’t doing it works.
here is an example of code that I tried to use to change the color of the window.

  #define DWMWA_TEXT_COLOR 36

		params.dwColorizationColor = RGB(0, 255, 0);  
		params.dwColorizationAfterglow = RGB(0, 0, 255); 
		params.dwColorizationColorBalance = RGB(255, 0, 0); 
		params.dwAlpha = 255;
		params.fOpaque = FALSE;

		DwmSetWindowAttribute(hwndHandler, DWMWA_CAPTION_COLOR, &params, sizeof(params));
		DwmSetWindowAttribute(hwndHandler, DWMWA_TEXT_COLOR, &params, sizeof(params));
		DwmSetWindowAttribute(hwndHandler, DWMWA_BORDER_COLOR, &params, sizeof(params));

		BOOL useDarkMode = TRUE;
		DwmSetWindowAttribute(hwndHandler, DWMWA_USE_IMMERSIVE_DARK_MODE, &useDarkMode, sizeof(useDarkMode));

the following code I wrote doesn’t work, is there any solution to solve this problem? did I put this code after the glfw window was created or im wrong?
and the variabile DWM_COLORIZATION_PARAMS dosen’t exixt in win32 so i have re-created the function

    DWORD dwColorizationColor;
    DWORD dwColorizationAfterglow;
    DWORD dwColorizationColorBalance;
    DWORD dwAlpha;
    BOOL  fOpaque;

From the documentation for the DwmSetWindowAttribute function’s enum DWMWINDOWATTRIBUTE the pvAttribute parameter should point to a value of type COLORREF which is simlpy a DWORD colour such as 0x000000FF for red.

You should link to dwmapi.lib, and get the HWND for your window using the native function access:

#define NOMINMAX
#include <GLFW/glfw3native.h>
#include "dwmapi.h"


    // create window and change border colour (this is only the thin surround border)
    GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
    HWND hwnd = glfwGetWin32Window(window);
    COLORREF colour = 0x000000FF;
    DwmSetWindowAttribute(hwnd, DWMWA_BORDER_COLOR, &colour, sizeof(colour) );

    // rest of code

The above code worked for me, though the border here is just the thin surround not the background of the caption.

sorry for my late response.
This function is correct and the program is actualy compiling, but im having a compatibility issue with windows 10… how can i fix without upgrading to windows 11?

I don’t think there is a way outside of Windows 11 Build 22000+.

The main alternative is to use an undecorated window and draw the controls yourself with a UI.