question

35448318 avatar image
0 Votes"
35448318 asked 35448318 answered

How to get "Active signal resolution"?

83349-asr.png


dotnet-csharpc++windows-api-general
asr.png (27.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

35448318 avatar image
1 Vote"
35448318 answered

Found the answer. DISPLAYCONFIG_VIDEO_SIGNAL_INFO::activeSize

ns-wingdi-displayconfig_video_signal_info


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered 35448318 commented

Please try the following code:

         private async Task<string> GetActiveSignalResolution()
         {
             var all = await DeviceInformation.FindAllAsync(DisplayMonitor.GetDeviceSelector());
             if (all != null)
             {
                 foreach (var info in all)
                 {
                     if (info.Kind == DeviceInformationKind.DeviceInterface)
                     {
                         var display = await DisplayMonitor.FromInterfaceIdAsync(info.Id);
                         if (display != null)
                         {
                             var size = display.NativeResolutionInRawPixels;
                             return size.Width.ToString() + " × " + size.Height.ToString();
                         }
                     }
                 }
             }
             throw new NotSupportedException();
         }

The code comes from this thread and it works for me after testing.

Because this code uses the UWP API, you need to install a nuget package: Microsoft.Windows.SDK.Contracts


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You just copied my code. I wrote this, and it doesn't work.

0 Votes 0 ·

@35448318
Well, your code was showing the current Active signal resolution when I tested it.
83458-2.png
Are there some steps I don’t know?
Could you please tell me what I should do to reproduce your problem?

0 Votes 0 ·
2.png (16.1 KiB)
35448318 avatar image 35448318 TimonYang-MSFT ·

If you change the resolution to 1280*960 or 1024*768 with "Display Adapter Properties of Display 1" and "List All Modes", then you will reproduce my problem.

0 Votes 0 ·