Hi, I currently have a program that will get each connected monitor location, once i get the location I atach a windows media player object to the desktop handle for each monitor, the problem is the locations are wrong.
1 Monitor returns X:0 Y: 0
2nd Monitor returns X:-1080 Y:0
3rd Monitor returns X: 1080, -130
When I run the program they are all bunched up on one monitor
One monitor is rotated and 768x1366
The other two are 1080x1920
DPI is 100% on all three.
What I have tried:
I have tried
Screen.allScreens[¡].bounds
and
Screen.allScreens[¡].workingArea
And this is the current code:
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace AnimateMyBackground {
public class ambScreen {
public string DeviceName {
get;
}
public int dmPelsHeight {
get;
}
public int dmPelsWidth {
get;
}
public int dmPositionX {
get;
}
public int dmPositionY {
get;
}
public Point Location {
get;
}
public Size Size {
get;
}
public ScreenOrientation dmDisplayOrientation {
get;
}
public ambScreen() {}
public ambScreen(string DeviceName, Size Size, Point Location, int dmPelsHeight, int dmPelsWidth, int dmPositionX, int dmPositionY, ScreenOrientation dmDisplayOrientation) {
this.DeviceName = DeviceName;
this.Size = Size;
this.Location = Location;
this.dmPositionX = dmPositionX;
this.dmPositionY = dmPositionY;
this.dmPelsHeight = dmPelsHeight;
this.dmPelsWidth = dmPelsWidth;
this.dmDisplayOrientation = dmDisplayOrientation;
}
}
public class Display {
private
const int ENUM_CURRENT_SETTINGS = -1;
public ambScreen ambScreen { get; } public WindowsMediaPlayer wmp { get; }
public bool enable { get; set; }
public bool autpPlay { get; set; }
public onStatusUpdate OnStatusUpdate { get; set; } = null;
public ToolStripMenuItem playNext { get; set; }
public ToolStripMenuItem playPrevious { get; set; }
public ToolStripMenuItem playerEnable { get; set; }
public ToolStripMenuItem playerRandom { get; set; }
public ToolStripMenuItem playerMute { get; set; }
public ToolStripMenuItem loopCurrent { get; set; }
private void doOnStatusUpdate(PlayEvent playEvent) { OnStatusUpdate?.Invoke(playEvent); }
public Display(Screen Screen, Control.ControlCollection Controls, int index) {
EnumDisplaySettings(Screen.DeviceName, ENUM_CURRENT_SETTINGS, ref dm);
ambScreen = new ambScreen(Screen.DeviceName, new Size(dm.dmPelsWidth, dm.dmPelsHeight), new Point(dm.dmPositionX, dm.dmPositionY), dm.dmPelsHeight, dm.dmPelsWidth, dm.dmPositionX, dm.dmPositionY, dm.dmDisplayOrientation); wmp = new WindowsMediaPlayer(Controls, index);
wmp.OnStatusUpdate += new onStatusUpdate(doOnStatusUpdate);
wmp.AxWindowsMediaPlayer.Hide(); } [DllImport("user32.dll")]
public static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode); [StructLayout(LayoutKind.Sequential)] public struct DEVMODE {
private const int CCHDEVICENAME = 0x20;
private const int CCHFORMNAME = 0x20; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
public string dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
public short dmSize; public short dmDriverExtra;
public int dmFields;
public int dmPositionX; public int dmPositionY;
public ScreenOrientation dmDisplayOrientation; public int dmDisplayFixedOutput; public short dmColor; public short dmDuplex; public short dmYResolution;
public short dmTTOption;
public short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
public string dmFormName;
public short dmLogPixels;
public int dmBitsPerPel;
public int dmPelsWidth;
public int dmPelsHeight;
public int dmDisplayFlags;
public int dmDisplayFrequency;
public int dmICMMethod;
public int dmICMIntent;
public int dmMediaType;
public int dmDitherType;
public int dmReserved1;
public int dmReserved2;
public int dmPanningWidth;
public int dmPanningHeight; } } }