我创建了一个获胜应用,它使用辅助显示器来显示图像。 我使用以下代码来检测和设置辅助监视器的位置(这是主监视器的扩展监视器)。
public void secondarydisplay()
{
FrmSecondaryDisplay secdis = new FrmSecondaryDisplay();
Screen[] screens = Screen.AllScreens;
secdis.MyBase = this;
this.MySecScreen = secdis;
secdis.Show();
setFormLocation(secdis, screens[1]);
}
private void setFormLocation(Form form, Screen screen)
{
Rectangle bounds = screen.Bounds;
form.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
form.StartPosition = FormStartPosition.Manual;
}
问题是我在辅助显示屏的最左边角落获得了这条细长的6mm白线。这只不过是主显示器的扩展。我怎么让它消失?将光标移动到辅助监视器并单击辅助监视器屏幕时,此白线消失。将光标移回主监视器并单击它会使白线显示在辅助监视器上。请帮助我如何解决这个问题。它在次要的mopnitor看起来很难看。
答案 0 :(得分:2)
始终在Show()
public void Secondarydisplay()
{
if (Screen.AllScreens.Count() == 1)
{
return; // No second display
}
var secdis = new FrmSecondaryDisplay();
// Actually you shall use secdis.Show(this) to build the relation of the forms.
// When "this" closes, the second display form closes.
secdis.MyBase = this;
this.MySecScreen = secdis;
// Setup Windows Position before Show()
secdis.StartPosition = FormStartPosition.Manual;
secdis.Location = Screen.AllScreens[1].WorkingArea.Location;
secdis.TopMost = true;
secdis.FormBorderStyle = FormBorderStyle.None;
secdis.WindowState = FormWindowState.Maximized;
secdis.Show(this); // See comment above
}