Post Reply

Forums -> UltraMon™ SDK -> Primären Bildschirm auswählen?
Torro14   2014-02-19 02:04
Ich habe folgendes vor:

-Pc(Windows 7) mit 3 Bildschirmen wovon jeweils nur einer gleichzeitig benutzt wird(also kein Clone, Extended)

-Per Commandozeile einen von den 3 Bildschirmen als Primären Monitor setzen.

Da dies unter WIn 7 wohl nicht so ohne weiteres Möglich ist, wollte ich hier mal nachfragen ob das mit dem UltraMon SDK machbar ist, und wenn ja, welche Funktionen muss ich da verwenden?
Torro14   2014-02-19 04:44
So I have writen al little test code to set the second screen as primary, but nothing happens.
I can read the information for both monitors, but the primary and enabled flag does not take any changes....where is the error?

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ULTRAMONLib;

namespace MonitorSwitcher
{
public partial class Form1 : Form
{
IUltraMonSystem2 sys = new UltraMonSystem();
IUltraMonMonitor[] mon;
int Monitoranzahl = 0;

public Form1()
{
InitializeComponent();
Monitoranzahl = sys.Monitors.Count;
mon = new IUltraMonMonitor[Monitoranzahl];
TextBox.Text += "Monitor Anzahl: " + Monitoranzahl + "\n";
for (int i = 0; i < Monitoranzahl; i++)
{
mon[i] = sys.Monitors[i];
}
}

private void btStart_Click(object sender, EventArgs e)
{

for (int i =0; i< Monitoranzahl;i++)
{
TextBox.Text += "\n";
TextBox.Text += "Monitor " + i + "\n";
TextBox.Text += "AdapterDeviceName: " + mon[i].AdapterDeviceName + "\n";
TextBox.Text += "AdapterName: " + mon[i].AdapterName + "\n";
TextBox.Text += "DeviceName: " + mon[i].DeviceName + "\n";
TextBox.Text += "RegKey: " + mon[i].DeviceRegKey + "\n";
TextBox.Text += "Enabled: " + mon[i].Enabled + "\n";
TextBox.Text += "Name: " + mon[i].Name + "\n";
TextBox.Text += "Removable: " + mon[i].Removable + "\n";
TextBox.Text += "Primary: " + mon[i].Primary + "\n";
TextBox.Text += "WindowsID: " + mon[i].WindowsID + "\n";
}
}

private void btMoni1_Click(object sender, EventArgs e)
{
if (Monitoranzahl > 0)
{
mon[0].Enabled = true;
mon[0].Primary = true;
TextBox.Text += "Monitor 1 Primary\n";
}
}

private void btMoni2_Click(object sender, EventArgs e)
{
if (Monitoranzahl > 1)
{
mon[1].Enabled = true;
mon[1].Primary = true;
TextBox.Text += "Monitor 2 Primary\n";
}
}
}
}
Christian Studer   2014-02-19 12:01
You're missing the call to the System object's ApplyMonitorChanges method, adding that to the click event handlers should fix the problem:

sys.ApplyMonitorChanges();

Christian Studer - www.realtimesoft.com
Forums -> UltraMon™ SDK -> Primären Bildschirm auswählen?

Post Reply