[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/linesight/cefpython/master/src/client_handler/dpi_aware.cpp [Back]  [Original]

// Copyright (c) 2014 CEF Python, see the Authors file.
// All rights reserved. Licensed under BSD 3-clause license.
// Project website: https://github.com/cztomczak/cefpython

// Windows only

#pragma comment(lib, "Gdi32.lib")
#include 

#include "dpi_aware.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/base/cef_bind.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_callback.h"

const int DEFAULT_DPIX = 96;

bool IsProcessDpiAware() {
    typedef BOOL(WINAPI *IsProcessDPIAwarePtr)(VOID);
    IsProcessDPIAwarePtr is_process_dpi_aware_func =
            reinterpret_cast(
                GetProcAddress(GetModuleHandleA("user32.dll"), 
                    "IsProcessDPIAware"));
    BOOL is_aware = FALSE;
    if (is_process_dpi_aware_func) {
        is_aware = is_process_dpi_aware_func();
        if (is_aware == TRUE) {
            return true;
        }
    }
    // GetProcessDpiAwareness is available only on Win8. So it
    // should be called only as a back-up plan after IsProcessDPIAware
    // was called. Also if IsProcessDPIAware returned false,
    // then GetProcessDpiAwareness is called as well.
    if (GetProcessDpiAwareness() != PROCESS_DPI_UNAWARE) {
        return true;
    }
    return false;
}

PROCESS_DPI_AWARENESS GetProcessDpiAwareness() {
    // Win8.1 supports monitor-specific DPI scaling, so it is
    // recommended to use GetProcessDPIAwareness instead of the
    // deprecated IsProcessDPIAware.
    typedef HRESULT(WINAPI *GetProcessDpiAwarenessPtr)
            (HANDLE,PROCESS_DPI_AWARENESS*);
    GetProcessDpiAwarenessPtr get_process_dpi_awareness_func =
            reinterpret_cast(
                GetProcAddress(GetModuleHandleA("user32.dll"),
                    "GetProcessDpiAwarenessInternal"));
    if (get_process_dpi_awareness_func) {
        HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false,
                GetCurrentProcessId());
        PROCESS_DPI_AWARENESS result;
        HRESULT hr = get_process_dpi_awareness_func(hProcess, &result);
        if (SUCCEEDED(hr)) {
            return result;
        }
        // Possible failures include E_INVALIDARG or E_ACCESSDENIED.
        LOG(INFO) 

Web Proxy Viewer  |  New URL  |  Original Page