Expand Minimize

GetScaleFactorForMonitor function

Gets the scale factor of a specific monitor. This function replaces GetScaleFactorForDevice.

Syntax


STDAPI GetScaleFactorForMonitor(
  _In_   HMONITOR hMon,
  _Out_  DEVICE_SCALE_FACTOR *pScale
);

Parameters

hMon [in]

The monitor's handle.

pScale [out]

When this function returns successfully, this value points to one of the DEVICE_SCALE_FACTOR values that specify the scale factor of the specified monitor.

If the function call fails, this value points to a valid scale factor so that apps can opt to continue on with incorrectly sized resources.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Your code needs to handle the WM_WINDOWPOSCHANGED message in addition to the scale change event registered through RegisterScaleChangeEvent, because the app window can be moved between monitors. In response to the WM_WINDOWPOSCHANGED message, call MonitorFromWindow, followed by GetScaleFactorForMonitor to get the scale factor of the monitor which the app window is on. Your code can then react to any dots per inch (dpi) change by reloading assets and changing layout.

Requirements

Minimum supported client

Windows 8.1 [desktop apps only]

Minimum supported server

Windows Server 2012 R2 [desktop apps only]

Header

ShellScalingAPI.h

Library

Shcore.lib

DLL

Shcore.dll

See also

RegisterScaleChangeEvent
UnregisterScaleChangeEvent

 

 

Community Additions

ADD
Show:
© 2014 Microsoft