forked from pyrite-dev/milsko
add MwLLSetDarkTheme
This commit is contained in:
parent
0fb9c45ea4
commit
a2c1489ffb
8 changed files with 57 additions and 1 deletions
|
|
@ -8,6 +8,14 @@ typedef struct userdata {
|
|||
int max_set;
|
||||
} userdata_t;
|
||||
|
||||
static struct symtbl {
|
||||
void* lib_dwmapi;
|
||||
|
||||
HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
||||
} wsymtbl;
|
||||
|
||||
#define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute
|
||||
|
||||
static void detect_darktheme(MwLL handle) {
|
||||
DWORD dw;
|
||||
DWORD sz = sizeof(dw);
|
||||
|
|
@ -26,6 +34,12 @@ static void detect_darktheme(MwLL handle) {
|
|||
|
||||
t = dw ? 0 : 1;
|
||||
|
||||
if(t && DwmSetWindowAttribute != NULL){
|
||||
LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE);
|
||||
BOOL v = TRUE;
|
||||
if(!(style & WS_CHILD)) DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
|
||||
}
|
||||
|
||||
MwLLDispatch(handle, dark_theme, &t);
|
||||
}
|
||||
|
||||
|
|
@ -804,7 +818,20 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
|||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle){
|
||||
BOOL v = toggle ? TRUE : FALSE;
|
||||
|
||||
DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
|
||||
|
||||
}
|
||||
|
||||
static int MwLLGDICallInitImpl(void) {
|
||||
memset(&wsymtbl, 0, sizeof(wsymtbl));
|
||||
|
||||
wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll");
|
||||
|
||||
if(wsymtbl.lib_dwmapi != NULL) DwmSetWindowAttribute = MwDynamicSymbol(wsymtbl.lib_dwmapi, "DwmSetWindowAttribute");
|
||||
|
||||
/* TODO: check properly */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue