Fix #101: Do not preview when Listary toolbar is visible

This commit is contained in:
Paddy Xu
2017-10-15 18:04:22 +03:00
parent 3f262dfcd2
commit 1b2f5fabfa
2 changed files with 31 additions and 2 deletions

View File

@@ -63,18 +63,44 @@ void HelperMethods::ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer)
DragQueryFile(HDROP(medium.hGlobal), 0, buffer, MAX_PATH - 1); DragQueryFile(HDROP(medium.hGlobal), 0, buffer, MAX_PATH - 1);
} }
bool HelperMethods::IsListaryToolbarVisible()
{
auto CALLBACK findListaryWindowProc = [](__in HWND hwnd, __in LPARAM lParam)-> BOOL
{
WCHAR classBuffer[MAX_PATH] = {'\0'};
if (FAILED(GetClassName(hwnd, classBuffer, MAX_PATH)))
return TRUE;
if (wcsncmp(classBuffer, L"Listary_WidgetWin_", 18) == 0)
{
if (IsWindowVisible(hwnd))
{
*reinterpret_cast<bool*>(lParam) = true;
return FALSE;
}
}
return TRUE;
};
auto found = false;
EnumWindows(findListaryWindowProc, reinterpret_cast<LPARAM>(&found));
return found;
}
bool HelperMethods::IsCursorActivated(HWND hwnd) bool HelperMethods::IsCursorActivated(HWND hwnd)
{ {
auto tId = GetWindowThreadProcessId(hwnd, nullptr); auto tId = GetWindowThreadProcessId(hwnd, nullptr);
GUITHREADINFO gui = {sizeof gui}; GUITHREADINFO gui = {sizeof gui};
GetGUIThreadInfo(tId, &gui); GetGUIThreadInfo(tId, &gui);
return gui.flags || gui.hwndCaret; return gui.flags || gui.hwndCaret || IsListaryToolbarVisible();
} }
bool HelperMethods::IsUWP() bool HelperMethods::IsUWP()
{ {
auto pGCPFN = decltype(&GetCurrentPackageFullName)(GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetCurrentPackageFullName")); auto pGCPFN = decltype(&GetCurrentPackageFullName)(
GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetCurrentPackageFullName"));
if (!pGCPFN) if (!pGCPFN)
return false; return false;

View File

@@ -23,4 +23,7 @@ public:
static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer); static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer);
static bool IsCursorActivated(HWND hwndfg); static bool IsCursorActivated(HWND hwndfg);
static bool HelperMethods::IsUWP(); static bool HelperMethods::IsUWP();
private:
static bool IsListaryToolbarVisible();
}; };