4

デュアル モニターのセットアップがあり、C# アプリケーションで特定の画面でウィンドウを最大化する必要があります。

どうやってやるの?

ありがとう!

4

4 に答える 4

4

これは、私のプロジェクトの 1 つにある同様のスコープの画面管理コードです。

        // screenId in my case is 1(first) or 2(second)
        int screenId = RegistryManager.ScreenId;
        // DualScreen management            
        if (screenId > 0)
        {
            // Have 2 screens
            if (System.Windows.Forms.Screen.AllScreens.Length == 2)
            {
                if (screenId == 1) // first
                    this.Location = new System.Drawing.Point(System.Windows.Forms.Screen.AllScreens[0].Bounds.Left, 0);
                else // second
                    this.Location = new System.Drawing.Point(System.Windows.Forms.Screen.AllScreens[1].Bounds.Left, 0);
            }
        }
于 2009-12-09T15:53:36.857 に答える
2

Screen クラスを使用して、2 番目のモニターリンクを見つけます。

コードはここにあります

function void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[1].Bounds.Width;
f.Top = sc[1].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[1].Bounds.Location;
Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}
于 2009-12-09T15:54:19.067 に答える
1

最大化する前にウィンドウを右または左に移動することで、これを機能させることができます。これにより、ウィンドウが最大化されたときに、ウィンドウがその画面に最大化されます。

于 2009-12-09T15:51:58.780 に答える
0
  Public Shared Sub MoveForm(Item As Form, ScreenNumber As Integer, Optional X As Integer = 0, Optional Y As Integer = 0)
    With Screen.AllScreens(ScreenNumber).Bounds
      X -= .Left 'translate overall coordinates to screen coordinates
      Y -= .Top
    End With
    Item.Location = New System.Drawing.Point(X, Y)
  End Sub
于 2012-05-23T21:11:28.723 に答える