I will describe the need:
For bug-reporting purpose, we include in our application a way for video-capture of the screen.
For this purpose, we use an open source library called OBS studio.
In a multi-monitor setup (virtually 100% of our customer base), we need to tell OBS which monitor to capture. OBS uses DirectX, which has a way to index the monitors, numbering them from 0.
Our application is a .net app. The 2 API calls that seem relevant are:
System.Windows.Forms.Screen.FromControl()
and
System.Windows.Forms.Screen.AllScreens
these static calls return a Screen object, or an array of screen objects ( .NET docs ).
Now the question:
- How do I find the DirectX monitor number for the main window of my app (given the .net "Screen"), so I can ask OBS to record it?
- In other words, how do I map the AllScreens array from .NET, to monitor indexes understood by DirectX?
Peace.