Here is some half finished work:
Code: Select all
; struct DISPLAYCONFIG_DEVICE_INFO_HEADER
NumPut( "uint", -3 ; DISPLAYCONFIG_DEVICE_INFO_GET_DPI_SCALE
, "uint", 28
, "uint", adapterID
, "uint", sourceID
, "int", 0 ; minScaleRel
, "int", 0
, "int", 0
, requestPacket := Buffer(28))
if !DllCall("DisplayConfigGetDeviceInfo", "ptr", requestPacket)
throw OSError()
; Each relative scaling value is defined as the number of steps from the recommended scaling.
; For example, if minScaleRel is -3, then the recommended scaling is 175%.
; This is because 100% is 3 steps down from 175%.
minScaleRel := NumGet(requestPacket, 16, "int")
curScaleRel := NumGet(requestPacket, 20, "int")
maxScaleRel := NumGet(requestPacket, 24, "int")
curScaleRel := max(minScaleRel, curScaleRel)
curScaleRel := min(maxScaleRel, curScaleRel)
NumPut( "uint", -4 ; DISPLAYCONFIG_DEVICE_INFO_SET_DPI_SCALE
, "uint", 28
, "uint", adapterID
, "uint", sourceID
, "int", minScaleRel ; desiredScaleRel
, setPacket := Buffer(28))
DllCall("DisplayConfigSetDeviceInfo", "ptr", setPacket)
/*
DISPLAYCONFIG_DEVICE_INFO_TYPE type;
UINT32 size;
LUID adapterId;
UINT32 id;
*/
/*
* struct DISPLAYCONFIG_SOURCE_DPI_SCALE_GET
* @brief used to fetch min, max, suggested, and currently applied DPI scaling values.
* All values are relative to the recommended DPI scaling value
* Note that DPI scaling is a property of the source, and not of target.
struct DISPLAYCONFIG_SOURCE_DPI_SCALE_GET
{
DISPLAYCONFIG_DEVICE_INFO_HEADER header;
* @brief min value of DPI scaling is always 100, minScaleRel gives no. of steps down from recommended scaling
* eg. if minScaleRel is -3 => 100 is 3 steps down from recommended scaling => recommended scaling is 175%
std::int32_t minScaleRel;
* @brief currently applied DPI scaling value wrt the recommended value. eg. if recommended value is 175%,
* => if curScaleRel == 0 the current scaling is 175%, if curScaleRel == -1, then current scale is 150%
std::int32_t curScaleRel;
* @brief maximum supported DPI scaling wrt recommended value
std::int32_t maxScaleRel;
};
*/
/*
* struct DISPLAYCONFIG_SOURCE_DPI_SCALE_SET
* @brief set DPI scaling value of a source
* Note that DPI scaling is a property of the source, and not of target.
struct DISPLAYCONFIG_SOURCE_DPI_SCALE_SET
{
DISPLAYCONFIG_DEVICE_INFO_HEADER header;
* @brief The value we want to set. The value should be relative to the recommended DPI scaling value of source.
* eg. if scaleRel == 1, and recommended value is 175% => we are trying to set 200% scaling for the source
int32_t scaleRel;
};
*/
/*
* struct DPIScalingInfo
* @brief DPI info about a source
* mininum : minumum DPI scaling in terms of percentage supported by source. Will always be 100%.
* maximum : maximum DPI scaling in terms of percentage supported by source. eg. 100%, 150%, etc.
* current : currently applied DPI scaling value
* recommended : DPI scaling value reommended by OS. OS takes resolution, physical size, and expected viewing distance
* into account while calculating this, however exact formula is not known, hence must be retrieved from OS
* For a system in which user has not explicitly changed DPI, current should eqaul recommended.
* bInitDone : If true, it means that the members of the struct contain values, as fetched from OS, and not the default
* ones given while object creation.
struct DPIScalingInfo
{
UINT32 mininum = 100;
UINT32 maximum = 100;
UINT32 current = 100;
UINT32 recommended = 100;
bool bInitDone = false;
};
*/