2
2
#include < cstdio>
3
3
4
4
HWND getWindow () {
5
- printf (" Press CRLT + H to make the currently focussed window borderless\n " );
5
+ printf (" Press CRLT + H to make the currently focussed window borderless" );
6
6
MSG msg;
7
7
while (GetMessage (&msg, NULL , 0 , 0 ) != 0 ) {
8
8
if (msg.message == WM_HOTKEY) {
@@ -19,10 +19,15 @@ int main() {
19
19
char windowTitle[100 ];
20
20
while (true ) {
21
21
window = getWindow ();
22
- SetWindowLong (window, GWL_STYLE, 0x00000000 );
23
- SetWindowLong (window, GWL_STYLE, 0x94000000 );
24
- SetWindowPos (window, HWND_TOPMOST, 0 , 0 , screenWidth, screenHeigth, NULL );
25
- GetWindowText (window, windowTitle, 100 );
26
- printf (" Set window: %s to borderless\n\n " , windowTitle);
22
+ if (window) {
23
+ GetWindowText (window, windowTitle, 100 );
24
+ if (windowTitle) {
25
+ SetWindowLongPtr (window, GWL_EXSTYLE, 0x00000000 );
26
+ SetWindowLongPtr (window, GWL_STYLE, 0x94000000 );
27
+ SetWindowPos (window, HWND_TOP, 0 , 0 , screenWidth, screenHeigth, NULL );
28
+
29
+ printf (" \n Set window: %s to borderless\n\n " , windowTitle);
30
+ }
31
+ }
27
32
}
28
33
}
0 commit comments