From 804f485b4d3eeb4c7bda90e03397134058107afb Mon Sep 17 00:00:00 2001 From: Tyler Parret True Date: Fri, 12 Apr 2024 20:49:31 +0800 Subject: [PATCH] [Fix] --- ExampleBasic/ExampleBasic.cpp | 16 ++++++++-------- WGC-Capture-with-OpenCV/include/ohms/WGC.h | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ExampleBasic/ExampleBasic.cpp b/ExampleBasic/ExampleBasic.cpp index a980f5a..fce2655 100644 --- a/ExampleBasic/ExampleBasic.cpp +++ b/ExampleBasic/ExampleBasic.cpp @@ -62,12 +62,9 @@ int TestNormal() { auto r_capture = ohms::wgc::ICapture::getInstance(); // Find Window. HWND hwnd = FindWindowW(TargetWindowClass, TargetWindowName); - if (hwnd == NULL) { - return 1; - } if (TestCaptureMonitor) { - HMONITOR hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); + HMONITOR hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); if (hmonitor == NULL) { return 2; } @@ -76,6 +73,9 @@ int TestNormal() { } } else { + if (hwnd == NULL) { + return 1; + } if (!IsWindow(hwnd) || IsIconic(hwnd)) { // Requirements for capture window. return 4; } @@ -114,12 +114,9 @@ int TestCallback() { auto r_capture = ohms::wgc::ICapture::getInstance(); // Find Window. HWND hwnd = FindWindowW(TargetWindowClass, TargetWindowName); - if (hwnd == NULL) { - return 1; - } if (TestCaptureMonitor) { - HMONITOR hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); + HMONITOR hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); if (hmonitor == NULL) { return 2; } @@ -128,6 +125,9 @@ int TestCallback() { } } else { + if (hwnd == NULL) { + return 1; + } if (!IsWindow(hwnd) || IsIconic(hwnd)) { // Requirements for capture window. return 4; } diff --git a/WGC-Capture-with-OpenCV/include/ohms/WGC.h b/WGC-Capture-with-OpenCV/include/ohms/WGC.h index 12f9d67..b516174 100644 --- a/WGC-Capture-with-OpenCV/include/ohms/WGC.h +++ b/WGC-Capture-with-OpenCV/include/ohms/WGC.h @@ -30,9 +30,7 @@ #include #include -#ifdef OHMS_WGC_USE_CALLBACK #include -#endif // OHMS_WGC_USE_CALLBACK namespace ohms { namespace wgc {