Skip to content

Commit 03c07f4

Browse files
Freestyle-CoderFreestyle-Coder
authored andcommitted
fixed some bugs + window is not topmost anymore
1 parent 77085cc commit 03c07f4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

borderless.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <cstdio>
33

44
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");
66
MSG msg;
77
while (GetMessage(&msg, NULL, 0, 0) != 0) {
88
if (msg.message == WM_HOTKEY) {
@@ -19,10 +19,15 @@ int main() {
1919
char windowTitle[100];
2020
while (true) {
2121
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("\nSet window: %s to borderless\n\n", windowTitle);
30+
}
31+
}
2732
}
2833
}

0 commit comments

Comments
 (0)