プライマリ ディスプレイを取得します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Shared ReadOnly Property PrimaryScreen As Screen
'使用
Dim value As Screen
value = Screen.PrimaryScreen
public static Screen PrimaryScreen { get; }
public:
static property Screen^ PrimaryScreen {
Screen^ get ();
}
/** @property */
public static Screen get_PrimaryScreen ()
public static function get PrimaryScreen () : Screen
プロパティ値
プライマリ ディスプレイ。
解説
ディスプレイが 1 台のシステムの場合、プライマリ ディスプレイが唯一のディスプレイです。
使用例
PrimaryScreen プロパティと GetWorkingArea メソッドの使用方法を次のコード例に示します。このメソッドには、Button1
という名前のボタンが配置されているフォームが必要です。
' This method will adjust the size of the form to utilize
' the working area of the screen.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea
' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width - 10, _
workingRectangle.Height - 10)
' Set the ___location so the entire form is visible.
Me.Location = New System.Drawing.Point(5, 5)
End Sub
// This method will adjust the size of the form to utilize
// the working area of the screen.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Retrieve the working rectangle from the Screen class
// using the PrimaryScreen and the WorkingArea properties.
System.Drawing.Rectangle workingRectangle =
Screen.PrimaryScreen.WorkingArea;
// Set the size of the form slightly less than size of
// working rectangle.
this.Size = new System.Drawing.Size(
workingRectangle.Width-10, workingRectangle.Height-10);
// Set the ___location so the entire form is visible.
this.Location = new System.Drawing.Point(5, 5);
}
// This method will adjust the size of the form to utilize
// the working area of the screen.
private:
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Retrieve the working rectangle from the Screen class
// using the PrimaryScreen and the WorkingArea properties.
System::Drawing::Rectangle workingRectangle = Screen::PrimaryScreen->WorkingArea;
// Set the size of the form slightly less than size of
// working rectangle.
this->Size = System::Drawing::Size( workingRectangle.Width - 10, workingRectangle.Height - 10 );
// Set the ___location so the entire form is visible.
this->Location = System::Drawing::Point( 5, 5 );
}
// This method will adjust the size of the form to utilize
// the working area of the screen.
private void button1_Click(Object sender, System.EventArgs e)
{
// Retrieve the working rectangle from the Screen class
// using the PrimaryScreen and the WorkingArea properties.
System.Drawing.Rectangle workingRectangle =
Screen.get_PrimaryScreen().get_WorkingArea();
// Set the size of the form slightly less than size of
// working rectangle.
this.set_Size(new System.Drawing.Size(workingRectangle.get_Width()
- 10, workingRectangle.get_Height() - 10));
// Set the ___location so the entire form is visible.
this.set_Location(new System.Drawing.Point(5, 5));
} //Button1_Click
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0