From ece89a04d63a833d48c8e79ea319df259e85fb0a Mon Sep 17 00:00:00 2001 From: ErrorFlynn Date: Tue, 23 May 2017 07:18:02 -0400 Subject: [PATCH] Add files via upload --- Borderless Window Helper/main.cpp | 16 +++++++++++----- Borderless Window Helper/main.h | 14 +++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Borderless Window Helper/main.cpp b/Borderless Window Helper/main.cpp index 4100a13..696341d 100644 --- a/Borderless Window Helper/main.cpp +++ b/Borderless Window Helper/main.cpp @@ -392,7 +392,7 @@ void mon_timer_fn() if(!win.borderless) // remove borders { MONITORINFO mi = {sizeof(mi)}; - GetMonitorInfoW(MonitorFromWindow(win.hwnd, MONITOR_DEFAULTTOPRIMARY), &mi); + GetMonitorInfoW(win.monitor, &mi); SetWindowLongPtr(win.hwnd, GWL_STYLE, (monwin.second.style & ~(WS_CAPTION|WS_THICKFRAME)) | WS_POPUP); SetWindowPos(win.hwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED); @@ -401,10 +401,15 @@ void mon_timer_fn() HWND fghwnd = GetForegroundWindow(); if(monwin.second.active) { - if(fghwnd != win.hwnd) + if(fghwnd != win.hwnd && win.monitor == MonitorFromWindow(fghwnd, MONITOR_DEFAULTTOPRIMARY)) { - monwin.second.active = false; - PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); + string fgclassname(1024, '\0'); + fgclassname.resize(GetClassNameA(fghwnd, &fgclassname.front(), fgclassname.size())); + if(fgclassname != "TaskSwitcherWnd") + { + monwin.second.active = false; + PostMessage(win.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); + } } } else if(fghwnd == win.hwnd) monwin.second.active = true; @@ -499,6 +504,7 @@ void enum_windows() filepath procpath(procname); win.procnamew = procpath.fullnamew(); win.hwnd = hwnd; + win.monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); win.captionw = caption; if(!(style & (WS_CAPTION|WS_THICKFRAME))) win.borderless = true; windows[procpath.fullname()] = win; @@ -590,4 +596,4 @@ void SaveSettings() ini.WriteString(s, "p", monwin.first); ini.WriteInt(s, "s", monwin.second.style); } -} +} \ No newline at end of file diff --git a/Borderless Window Helper/main.h b/Borderless Window Helper/main.h index aeb867f..50c602a 100644 --- a/Borderless Window Helper/main.h +++ b/Borderless Window Helper/main.h @@ -5,15 +5,14 @@ #include "util.h" #include -#include #include #pragma warning( disable : 4800 4267 4996) #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#define TITLE "Borderless Window Helper 1.0" -#define TITLEW L"Borderless Window Helper 1.0" +#define TITLE "Borderless Window Helper 1.1" +#define TITLEW L"Borderless Window Helper 1.1" using namespace std; using namespace nana; @@ -21,7 +20,7 @@ using namespace nana; string last; wstring inifile; filepath self_path; -HWND hwnd, balloon(0); +HWND hwnd; bool mintray(true); struct monwin @@ -36,7 +35,12 @@ map monwins; struct enumwin { - DWORD procid = 0; wstring procnamew; HWND hwnd; wstring captionw; bool borderless = false; + DWORD procid = 0; + wstring procnamew; + HWND hwnd = nullptr; + HMONITOR monitor = nullptr; + wstring captionw; + bool borderless = false; }; map windows;