简体   繁体   中英

From Qt, under Win7, how to know which window style is used for display?

I'd like to workaround this bug . So I need to know if user display configuration under Window7 is using "Aero" or "Classic" style.

Is there a way to do that?

I tried QApplication::style()->objectName() but this alsways returns me "windowsvista" whatever style is selected....

That can be done with WinAPI. In case of Windows 7 (and possibly Vista, 8 and 10):

// true == Aero theme, false == Classic theme
bool isAeroEnabled()
{
    HMODULE library = LoadLibrary(L"dwmapi.dll");
    bool result = false;
    if (library) {
        BOOL enabled = false;
        HRESULT (WINAPI *pFn)(BOOL *enabled) = (HRESULT (WINAPI *)(BOOL *enabled))(GetProcAddress(library, "DwmIsCompositionEnabled"));
        result = SUCCEEDED(pFn(&enabled)) && enabled;
        FreeLibrary(library);
    }
    return result;
}

For older Windows versions please follow to Get Windows theme? question.

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