No announcement yet.

Monitor Selection and Getting Supported Fullscreen Resolutions for Each Monitor

  • Filter
  • Time
  • Show
Clear All
new posts

    Monitor Selection and Getting Supported Fullscreen Resolutions for Each Monitor

    I have created a BlueprintCallable function that will set which monitor my game will display on. My problem is that Get Supported Fullscreen Resolutions will only return the supported resolutions for my primary monitor, it seems.
    I have a combo box of supported resolutions, and when the monitor selection combo box value is changed, I have the resolutions combo box emptied.
    Then the viewport is changed over to the selected monitor, I call Get Supported Fullscreen Resolutions again, but end up populating the resolutions combo box with the same resolutions.
    I would think that Get Supported Fullscreen Resolutions would get the current monitor's supported resolutions, but it does not.
    Both my monitors are of different aspect ratios and have different supported resolutions, and should be getting different resolutions.
    My primary monitor's native, and maximum, resolution is 1920x1080p and my second monitor's native and maximum is 1920x1200p.
    As a work around, I suppose I could add the selected monitor's native resolution to the resolution combo box if it doesn't exist. But I'd really prefer getting a complete list for whichever monitor is selected.
    Is there any way of doing this? Doing more C++ code is not a problem.

    Using UE 4.24.3

    There is some cleanup code yet to be added, but I have solved my problem. Posting the code for others:
    Be sure to include:
    #include "AllowWindowsPlatformTypes.h"
    #include "Windows.h"
    #include "HideWindowsPlatformTypes.h"
    My struct for the data:

    struct FDisplayDeviceAndSupportedResolutions {
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            int32 DeviceNumber;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            FString DeviceName;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            FString DeviceString;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            FString DeviceID;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            FString DeviceKey;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            TArray<FString> SupportedResolutions;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            bool IsPrimary;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
            FString AttachedMonitorString;
    And lastly, the code that does the thing:

    //Info from
    //and also from
    TArray<FDisplayDeviceAndSupportedResolutions> GetDisplayDevicesAndSupportedResolutions() {
        TArray<FDisplayDeviceAndSupportedResolutions> arrDisplayDeviceAndSupportedResolutions;
        TArray<DISPLAY_DEVICE> arrDD;
        DISPLAY_DEVICE dd = { 0 };
        dd.cb = sizeof(DISPLAY_DEVICE);
        //First, get info on display adapter by calling with lpDevice NULL
        for (int adapterNum = 0; EnumDisplayDevices(NULL, adapterNum, &dd, 0) != 0; adapterNum++) {        
            if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
                FDisplayDeviceAndSupportedResolutions item;
                item.DeviceNumber = adapterNum;
                item.DeviceID = dd.DeviceID;
                item.DeviceName = dd.DeviceName;
                item.DeviceString = dd.DeviceString;
                item.SupportedResolutions = GetResolutionsForDisplayDevice(dd);
                //Get monitor info
                DISPLAY_DEVICE ddm = { 0 };
                ddm.cb = sizeof(DISPLAY_DEVICE);
                EnumDisplayDevices((LPWSTR)dd.DeviceName, 0, &ddm, 0);
                TArray<FString> parts;
                FString deviceId = ddm.DeviceID;
                deviceId.ParseIntoArray(parts, TEXT("\\"), true);
                if (parts.Num() > 1) {
                    item.AttachedMonitorString = FString(ddm.DeviceString) + " - " + parts[1];
                else {
                    item.AttachedMonitorString = ddm.DeviceString;
                if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
                    item.IsPrimary = true;
        return arrDisplayDeviceAndSupportedResolutions;
    //Info from
    TArray<FString>GetResolutionsForDisplayDevice(DISPLAY_DEVICE &dd) {
        TArray<FString> resolutions;
        DEVMODE dm = { 0 };
        dm.dmSize = sizeof(DEVMODE);
        dm.dmDriverExtra = 0;
        for (uint32 i = 0; EnumDisplaySettings(dd.DeviceName, i, &dm) != 0; i++) {
            resolutions.AddUnique(FString::FromInt(dm.dmPelsWidth) + "x" + FString::FromInt(dm.dmPelsHeight));
        return resolutions;
    Last edited by ehenry; 04-04-2020, 12:54 PM.