6
6
#define HK_ID 1
7
7
8
8
HWND HWNDPrev = NULL ;
9
- WCHAR className [32 ];
10
9
HWINEVENTHOOK hHook ;
11
- BOOL lpol , tpol ;
10
+ BOOL tPol , tPeek , isEnabled ;
12
11
13
12
14
13
DWORD GetPID (const char * processName ) {
@@ -40,7 +39,7 @@ DWORD GetPID(const char* processName) {
40
39
41
40
const char * GetExcludeList ()
42
41
{
43
- static char pBuffer [64 ];
42
+ static char pBuffer [64 ]; // Usamos static para que la variable persista fuera del alcance de la función
44
43
DWORD pSize = sizeof (pBuffer );
45
44
46
45
// Leer la lista de procesos excluidos
@@ -55,6 +54,7 @@ const char* GetExcludeList()
55
54
56
55
if (RegQueryValueExA (hKey , "ExclusionList" , NULL , & valueType , (LPBYTE )pBuffer , & pSize ) != ERROR_SUCCESS ){
57
56
const char * initialValue = "explorer.exe\0\0" ;
57
+
58
58
RegSetValueExA (hKey , "ExclusionList" , 0 , REG_MULTI_SZ , (const BYTE * )initialValue , strlen (initialValue ));
59
59
}
60
60
@@ -64,43 +64,55 @@ const char* GetExcludeList()
64
64
return pBuffer ;
65
65
}
66
66
67
- void _PoL (HWND hwnd , const char * Option )
67
+ void _NCRP (HWND hwnd , const char * Option )
68
68
{
69
- //politica de renderizado y transisiones
69
+ //politica de renderizado
70
70
if (strcmp (Option , "Enable" ) == 0 ) {
71
71
DWMNCRENDERINGPOLICY rNCRP = DWMNCRP_ENABLED ;
72
- tpol = FALSE;
73
72
DwmSetWindowAttribute (hwnd , DWMWA_NCRENDERING_POLICY , & rNCRP , sizeof (rNCRP ));
74
- DwmSetWindowAttribute ( hwnd , DWMWA_TRANSITIONS_FORCEDISABLED , & tpol , sizeof ( tpol ));
73
+
75
74
} else if (strcmp (Option , "Disable" ) == 0 ) {
76
75
DWMNCRENDERINGPOLICY NCRP = DWMNCRP_DISABLED ;
77
- lpol = TRUE;
78
76
DwmSetWindowAttribute (hwnd , DWMWA_NCRENDERING_POLICY , & NCRP , sizeof (NCRP ));
79
- DwmSetWindowAttribute (hwnd , DWMWA_TRANSITIONS_FORCEDISABLED , & lpol , sizeof (lpol ));
80
77
}
81
78
}
82
79
83
- void _DisableBlurBehind (HWND hWnd )
80
+ void _ATTRIBS_OFF (HWND hwnd )
84
81
{
85
- //politica de transparencia
86
- DWM_BLURBEHIND bb = {0 };
87
- bb .dwFlags = DWM_BB_ENABLE ;
88
- bb .fEnable = FALSE;
89
- bb .hRgnBlur = NULL ;
82
+ //politica de transisiones, icon_peek,
83
+ tPol = TRUE;
84
+ tPeek = FALSE;
85
+ DwmSetWindowAttribute (hwnd , DWMWA_TRANSITIONS_FORCEDISABLED , & tPol , sizeof (tPol ));
86
+ DwmSetWindowAttribute (hwnd , DWMWA_DISALLOW_PEEK , & tPeek , sizeof (tPeek ));
87
+ DwmSetWindowAttribute (hwnd , DWMWA_FORCE_ICONIC_REPRESENTATION , & tPol , sizeof (tPol ));
88
+ }
90
89
91
- DwmEnableBlurBehindWindow (hWnd , & bb );
90
+ void _ATTRIBS_ON (HWND hwnd )
91
+ {
92
+ tPol = FALSE;
93
+ tPeek = TRUE;
94
+ DwmSetWindowAttribute (hwnd , DWMWA_TRANSITIONS_FORCEDISABLED , & tPol , sizeof (tPol ));
95
+ DwmSetWindowAttribute (hwnd , DWMWA_DISALLOW_PEEK , & tPeek , sizeof (tPeek ));
96
+ DwmSetWindowAttribute (hwnd , DWMWA_FORCE_ICONIC_REPRESENTATION , & tPol , sizeof (tPol ));
92
97
}
93
98
94
99
BOOL IsExcludeHWND (HWND hWnd_ex )
95
100
{
101
+
102
+ // Verificar si la ventana tiene la renderización habilitada
103
+ DwmGetWindowAttribute (hWnd_ex , DWMWA_NCRENDERING_ENABLED , & isEnabled , sizeof (isEnabled ));
104
+ if (isEnabled == FALSE) {
105
+ return TRUE;
106
+ }
107
+
96
108
DWORD pid ;
97
109
GetWindowThreadProcessId (hWnd_ex , & pid );
98
110
99
111
const char * pBuffer = GetExcludeList ();
100
112
101
113
// Verificar si el proceso de la ventana está en la lista de exclusión
102
114
while (* pBuffer ) {
103
- DWORD pid_ex = GetPID (pBuffer );
115
+ DWORD pid_ex = GetPID (pBuffer ); // Aquí deberías llamar a tu función GetPID
104
116
if (pid == pid_ex ) {
105
117
return TRUE;
106
118
}
@@ -111,24 +123,26 @@ BOOL IsExcludeHWND(HWND hWnd_ex)
111
123
}
112
124
113
125
BOOL CALLBACK PolWinProc (HWND hwnd , LPARAM lParam ) {
114
- _PoL (hwnd , "Disable" );
126
+ _NCRP (hwnd , "Disable" );
127
+ _ATTRIBS_OFF (hwnd );
115
128
116
129
// Comprobar si la ventana es de un proceso excluido
117
130
if (IsExcludeHWND (hwnd ))
118
131
{
119
- _PoL (hwnd , "Enable" );
132
+ _NCRP (hwnd , "Enable" );
120
133
}
121
134
return TRUE;
122
135
}
123
136
124
137
BOOL CALLBACK dPolWinProc (HWND hwnd , LPARAM lParam ) {
125
- _PoL (hwnd , "Enable" );
138
+ _NCRP (hwnd , "Enable" );
139
+ _ATTRIBS_ON (hwnd );
126
140
return TRUE;
127
141
}
128
142
129
143
void CALLBACK WinEventProc (HWINEVENTHOOK hWinEventHook , DWORD event , HWND hwnd , LONG idObject , LONG idChild , DWORD dwEventThread , DWORD dwmsEventTime )
130
144
{
131
- if (event == EVENT_SYSTEM_FOREGROUND && hwnd != HWNDPrev && hwnd != NULL )
145
+ if (event == EVENT_SYSTEM_FOREGROUND && hwnd != HWNDPrev )
132
146
{
133
147
// Comprobar si la ventana actual es de un proceso excluido
134
148
if (IsExcludeHWND (hwnd ))
@@ -137,8 +151,8 @@ void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd,
137
151
}
138
152
139
153
// Deshabilitar la política en la ventana anterior
140
- _PoL (hwnd , "Disable" );
141
- _DisableBlurBehind (hwnd );
154
+ _NCRP (hwnd , "Disable" );
155
+ _ATTRIBS_OFF (hwnd );
142
156
143
157
// Actualizar HWNDPrev con el valor de la ventana actual
144
158
HWNDPrev = hwnd ;
0 commit comments