简体   繁体   中英

I included <winuser.h>, but compiler throws "was not declared" at MonitorFromWindow

There is already a post about it, but it didn't solve the error. I tried commenting out the if on winuser.h, but it did no effect.

// Header
    #include <windows.h>
    #include <winuser.h>

// Cpp
 monitorA = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); // Errors
    GetMonitorInfo(monitorA, &monitorAInfo); // No error

error: 'MonitorFromWindow' was not declared in this scope

error: 'MONITOR_DEFAULTTOPRIMARY' was not declared in this scope

Also, I am using Code::blocks with gcc compiler.

Assuming your copy of <winuser.h> actually supports MonitorFromWindow() , then make sure that you have WINVER set to 0x0500 or higher to enable MonitorFromWindow() . See the following for more details:

Using the Windows Headers: Setting WINVER or _WIN32_WINNT

Update WINVER and _WIN32_WINNT

What's the difference between WINVER, _WIN32_WINNT, _WIN32_WINDOWS, and _WIN32_IE?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM