Ejemplo n.º 1
0
EXPORT QRect screenGeometry(unsigned nScreen)
{
#if QT_VERSION >= 300
    QDesktopWidget *desktop = QApplication::desktop();
    return desktop->screenGeometry(nScreen);
#else 
#ifdef WIN32
    HINSTANCE hLib = LoadLibraryA("user32.dll");
    BOOL (WINAPI *_EnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL;
    (DWORD&)_EnumDisplayMonitors = (DWORD)GetProcAddress(hLib, "EnumDisplayMonitors");
    if (_EnumDisplayMonitors == NULL){
        FreeLibrary(hLib);
        return QApplication::desktop()->rect();
    }
    vector<QRect> rc;
    if (_EnumDisplayMonitors(NULL, NULL, enumScreens, (LPARAM)&rc) == 0){
        FreeLibrary(hLib);
        return QApplication::desktop()->rect();
    }
    return rc[nScreen];
#else
    return QApplication::desktop()->rect();
#endif
#endif
}
Ejemplo n.º 2
0
EXPORT QRect screenGeometry()
{
#if QT_VERSION >= 300
    QDesktopWidget *desktop = QApplication::desktop();
    QRect rc;
    for (int i = 0; i < desktop->numScreens(); i++){
        rc |= desktop->screenGeometry(i);
    }
    return rc;
#else 
#ifdef WIN32
    HINSTANCE hLib = LoadLibraryA("user32.dll");
    BOOL (WINAPI *_EnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL;
    (DWORD&)_EnumDisplayMonitors = (DWORD)GetProcAddress(hLib, "EnumDisplayMonitors");
    if (_EnumDisplayMonitors == NULL){
        FreeLibrary(hLib);
        return QApplication::desktop()->rect();
    }
    vector<QRect> rc;
    if (_EnumDisplayMonitors(NULL, NULL, enumScreens, (LPARAM)&rc) == 0){
        FreeLibrary(hLib);
        return QApplication::desktop()->rect();
    }
    QRect res;
    for (vector<QRect>::iterator it = rc.begin(); it != rc.end(); ++it)
        res |= (*it);
    return res;
#else
    return QApplication::desktop()->rect();
#endif
#endif
}
Ejemplo n.º 3
0
EXPORT unsigned screens()
{
#if COMPAT_QT_VERSION >= 0x030000
    QDesktopWidget *desktop = QApplication::desktop();
    return desktop->numScreens();
#else 
#ifdef WIN32
    HINSTANCE hLib = LoadLibraryA("user32.dll");
    BOOL (WINAPI *_EnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL;
    (DWORD&)_EnumDisplayMonitors = (DWORD)GetProcAddress(hLib, "EnumDisplayMonitors");
    if (_EnumDisplayMonitors == NULL){
        FreeLibrary(hLib);
        return 1;
    }
    vector<QRect> rc;
    if (_EnumDisplayMonitors(NULL, NULL, enumScreens, (LPARAM)&rc) == 0){
        FreeLibrary(hLib);
        return 1;
    }
    return rc.size();
#else
    return 1;
#endif
#endif
}