start tracking already topmost on start
This commit is contained in:
parent
82cba89f7d
commit
4d888627e8
|
@ -11,6 +11,7 @@ AlwaysOnTop::AlwaysOnTop()
|
|||
{
|
||||
s_instance = this;
|
||||
Init();
|
||||
StartTrackingTopmostWindows();
|
||||
}
|
||||
|
||||
AlwaysOnTop::~AlwaysOnTop()
|
||||
|
@ -78,6 +79,38 @@ void AlwaysOnTop::ProcessCommand(HWND window)
|
|||
}
|
||||
}
|
||||
|
||||
void AlwaysOnTop::StartTrackingTopmostWindows()
|
||||
{
|
||||
using result_t = std::vector<HWND>;
|
||||
result_t result;
|
||||
|
||||
auto enumWindows = [](HWND hwnd, LPARAM param) -> BOOL {
|
||||
if (!IsWindowVisible(hwnd))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
auto windowName = GetWindowTextLength(hwnd);
|
||||
if (windowName > 0)
|
||||
{
|
||||
result_t& result = *reinterpret_cast<result_t*>(param);
|
||||
result.push_back(hwnd);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
EnumWindows(enumWindows, reinterpret_cast<LPARAM>(&result));
|
||||
|
||||
for (HWND window : result)
|
||||
{
|
||||
if (IsTopmost(window))
|
||||
{
|
||||
topmostWindows.push_back(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AlwaysOnTop::ResetAll()
|
||||
{
|
||||
for (HWND topWindow : topmostWindows)
|
||||
|
|
|
@ -33,6 +33,7 @@ private:
|
|||
LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
|
||||
|
||||
void ProcessCommand(HWND window);
|
||||
void StartTrackingTopmostWindows();
|
||||
void ResetAll();
|
||||
void CleanUp();
|
||||
|
||||
|
|
Loading…
Reference in a new issue