Skip to content

Enabling displays does not work #12

Open

Description

@novacto3

Hello,

I tried to use the new version of Your library and it seems that enabling displays stopped working.
The sample throws an exception for "DeviceContext: Enable All" in

var validSetting = display.DisplayScreen.GetPreferredSetting();

because display.DisplayScreen is null. I tried to enable displays in my code via API call but it did not work either.

Activity

  1. falahati commented on Jun 15, 2020

    @falahati
    Owner

    Hey,

    This is the master branch, right? Since the latest release and the NuGet package don't have the DisplayScreen class yet.

    I will take a look at that. Thanks for reporting.

  2. self-assigned this
    on Jun 15, 2020
  3. novacto3 commented on Jun 15, 2020

    @novacto3
    Author

    Yes, sorry for not specifying that. Let me know if I can be of any help with this.

  4. novacto3 commented on Jun 15, 2020

    @novacto3
    Author

    I checked the v1.3.0.13 release and it does not work either. No exception is raised, but the disabled display is not enabled. In v1.2.0.2 it works fine.

  5. falahati commented on Jun 15, 2020

    @falahati
    Owner

    What you are trying to do? The DriverContext API is a legacy and might not work as expected. Especially if you are trying to enable a device that was connected to a display source or if it was in a clone group. You simply can't do much.

    I suggest using classes inside the DisplayConfig namespace. Find your physical device using the PathDisplayTarget and create a logical desktop corresponding to using the PathDisplaySource class then wire them all together and apply the configuration using the PathInfo class.

    I gave more descriptive information in the following issues:
    falahati/NvAPIWrapper#8 (comment)
    falahati/NvAPIWrapper#26 (comment)

  6. novacto3 commented on Jun 15, 2020

    @novacto3
    Author

    I have a display that is "disconnected" (in the terminology of Windows display settings) - it is connected, but disabled. Calling
    display.Enable(new WindowsDisplayAPI.DisplaySetting(display.GetPreferedSetting()));
    in previous versions of Your library started the display (that is the desired state for me). This functionality is not present in the latest release. Is it a bug or a feature? :-)

  7. falahati commented on Jun 15, 2020

    @falahati
    Owner

    I don't think I change anything related to this with the last release, give me a moment to check it on my device. So the v1.2 or the v1.1 works but v1.3 fails? What are the values of the unattached display's properties? Does it have a valid display name? ("//DISPLAY1", "//DISPLAY2" ...) And is there an already attached display that has the same name?

  8. novacto3 commented on Jun 15, 2020

    @novacto3
    Author

    I found the bug. In previous versions (tested on v1.1 and v1.2) the attached displays had names "//DISPLAY1", "//DISPLAY2", "//DISPLAY3" and the unattached display had name "//DISPLAY4". In the new release (v1.3), the attached display names stay the same, but the unattached display has the name "//DISPLAY2" (so there is a duplicity in the naming).

  9. falahati commented on Jun 15, 2020

    @falahati
    Owner

    Ok, the only change between the version that might be remotely related is the changes to the GetDisplayDevices() method. I will take another look into that. Meanwhile, if you don't need the DPI functionality you can use v1.2 safely.

    Thanks for reporting this issue

  10. nxnxfly commented on Dec 16, 2020

    @nxnxfly
    [DllImport("user32")]
    public static extern Win32Status DisplayConfigGetDeviceInfo(
        ref DisplayConfigSupportVirtualResolution targetSupportVirtualResolution
    );

    Does it work well?

    This is the Windows api:

    WINUSERAPI LONG WINAPI DisplayConfigGetDeviceInfo( Inout_ DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket);

    And How convert DisplayConfigSupportVirtualResolution to DISPLAYCONFIG_DEVICE_INFO_HEADER?

  11. falahati commented on Dec 17, 2020

    @falahati
    Owner

    Yes, that part is correct. It is not the source of the problem.
    You see, DisplayConfigGetDeviceInfo fills data based on the header of the passed struct. So in this case, DisplayConfigSupportVirtualResolution is a struct that is used to get virtual resolution information. What you are seeing in the native signature as DISPLAYCONFIG_DEVICE_INFO_HEADER is actually defined as DisplayConfigDeviceInfoHeader in this library and is included as the header of the DisplayConfigSupportVirtualResolution to notify the native method of the type of the data requested.

    Check here:

    [MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;

    And here:
    https://github.com/falahati/WindowsDisplayAPI/blob/62e27b37dd1a3aa4e49a36286ae39b5aee7f3671/WindowsDisplayAPI/Native/DisplayConfig/Structures/DisplayConfigDeviceInfoHeader.cs

  12. madmagic007 commented on Dec 1, 2024

    @madmagic007

    end of 2024, trying to enable a display on the latest nuget package still does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions