Console.SetWindowSize(Int32, Int32) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
콘솔 창의 높이와 너비를 지정한 값으로 설정합니다.
public:
static void SetWindowSize(int width, int height);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void SetWindowSize (int width, int height);
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static void SetWindowSize (int width, int height);
public static void SetWindowSize (int width, int height);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member SetWindowSize : int * int -> unit
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member SetWindowSize : int * int -> unit
static member SetWindowSize : int * int -> unit
Public Shared Sub SetWindowSize (width As Integer, height As Integer)
매개 변수
- width
- Int32
콘솔 창의 너비(열)입니다.
- height
- Int32
콘솔 창의 높이(행)입니다.
- 특성
예외
width
또는 height
가 0보다 작거나 같습니다.
또는
width
더하기 WindowLeft 또는 height
더하기 WindowTop 는 Int16.MaxValue보다 크거나 같습니다.
또는
width
또는 height
가 최대 창 너비 또는 현재 화면 해상도 및 콘솔 글꼴의 높이보다 큽니다.
사용자에게 이 작업을 수행할 권한이 없습니다.
I/O 오류가 발생했습니다.
현재 운영 체제는 Windows가 아닙니다.
예제
이 예제에서는 SetWindowSize 메서드 및 WindowWidth 및 WindowHeight 속성을 보여 줍니다. 콘솔 창 크기를 변경하는 전체 효과를 보려면 예제를 실행해야 합니다.
이 예제에서는 85개의 열과 43개의 행으로 설정된 콘솔 창의 크기를 보고한 다음 키를 누를 때까지 기다립니다. 키를 누르면 콘솔 창의 크기가 반으로 줄고, 새 차원이 보고되고, 예제에서 다른 키 누름을 기다립니다. 마지막으로 키를 누르면 콘솔 창이 원래 차원으로 복원되고 예제가 종료됩니다.
// This example demonstrates the Console.SetWindowSize method,
// the Console.WindowWidth property,
// and the Console.WindowHeight property.
using namespace System;
int main()
{
int origWidth;
int width;
int origHeight;
int height;
String^ m1 = "The current window width is {0}, and the "
"current window height is {1}.";
String^ m2 = "The new window width is {0}, and the new "
"window height is {1}.";
String^ m4 = " (Press any key to continue...)";
//
// Step 1: Get the current window dimensions.
//
origWidth = Console::WindowWidth;
origHeight = Console::WindowHeight;
Console::WriteLine( m1, Console::WindowWidth, Console::WindowHeight );
Console::WriteLine( m4 );
Console::ReadKey( true );
//
// Step 2: Cut the window to 1/4 its original size.
//
width = origWidth / 2;
height = origHeight / 2;
Console::SetWindowSize( width, height );
Console::WriteLine( m2, Console::WindowWidth, Console::WindowHeight );
Console::WriteLine( m4 );
Console::ReadKey( true );
//
// Step 3: Restore the window to its original size.
//
Console::SetWindowSize( origWidth, origHeight );
Console::WriteLine( m1, Console::WindowWidth, Console::WindowHeight );
}
/*
This example produces the following results:
The current window width is 85, and the current window height is 43.
(Press any key to continue...)
The new window width is 42, and the new window height is 21.
(Press any key to continue...)
The current window width is 85, and the current window height is 43.
*/
// This example demonstrates the Console.SetWindowSize method,
// the Console.WindowWidth property,
// and the Console.WindowHeight property.
using System;
class Sample
{
public static void Main()
{
int origWidth, width;
int origHeight, height;
string m1 = "The current window width is {0}, and the " +
"current window height is {1}.";
string m2 = "The new window width is {0}, and the new " +
"window height is {1}.";
string m4 = " (Press any key to continue...)";
//
// Step 1: Get the current window dimensions.
//
origWidth = Console.WindowWidth;
origHeight = Console.WindowHeight;
Console.WriteLine(m1, Console.WindowWidth,
Console.WindowHeight);
Console.WriteLine(m4);
Console.ReadKey(true);
//
// Step 2: Cut the window to 1/4 its original size.
//
width = origWidth/2;
height = origHeight/2;
Console.SetWindowSize(width, height);
Console.WriteLine(m2, Console.WindowWidth,
Console.WindowHeight);
Console.WriteLine(m4);
Console.ReadKey(true);
//
// Step 3: Restore the window to its original size.
//
Console.SetWindowSize(origWidth, origHeight);
Console.WriteLine(m1, Console.WindowWidth,
Console.WindowHeight);
}
}
/*
This example produces the following results:
The current window width is 85, and the current window height is 43.
(Press any key to continue...)
The new window width is 42, and the new window height is 21.
(Press any key to continue...)
The current window width is 85, and the current window height is 43.
*/
// This example demonstrates the Console.SetWindowSize method,
// the Console.WindowWidth property,
// and the Console.WindowHeight property.
open System
//
// Step 1: Get the current window dimensions.
//
let origWidth = Console.WindowWidth
let origHeight = Console.WindowHeight
printfn $"The current window width is {Console.WindowWidth}, and the current window height is {Console.WindowHeight}."
printfn " (Press any key to continue...)"
Console.ReadKey true |> ignore
//
// Step 2: Cut the window to 1/4 its original size.
//
let width = origWidth / 2
let height = origHeight / 2
Console.SetWindowSize(width, height)
printfn $"The new window width is {Console.WindowWidth}, and the new window height is {Console.WindowHeight}."
printfn " (Press any key to continue...)"
Console.ReadKey true |> ignore
//
// Step 3: Restore the window to its original size.
//
Console.SetWindowSize(origWidth, origHeight)
printfn $"The current window width is {Console.WindowWidth}, and the current window height is {Console.WindowHeight}."
// This example produces the following results:
//
// The current window width is 85, and the current window height is 43.
// (Press any key to continue...)
// The new window width is 42, and the new window height is 21.
// (Press any key to continue...)
// The current window width is 85, and the current window height is 43.
' This example demonstrates the Console.SetWindowSize method,
' the Console.WindowWidth property,
' and the Console.WindowHeight property.
Class Sample
Public Shared Sub Main()
Dim origWidth, width As Integer
Dim origHeight, height As Integer
Dim m1 As String = "The current window width is {0}, and the " & _
"current window height is {1}."
Dim m2 As String = "The new window width is {0}, and the new " & _
"window height is {1}."
Dim m4 As String = " (Press any key to continue...)"
'
' Step 1: Get the current window dimensions.
'
origWidth = Console.WindowWidth
origHeight = Console.WindowHeight
Console.WriteLine(m1, Console.WindowWidth, Console.WindowHeight)
Console.WriteLine(m4)
Console.ReadKey(True)
'
' Step 2: Cut the window to 1/4 its original size.
'
width = origWidth / 2
height = origHeight / 2
Console.SetWindowSize(width, height)
Console.WriteLine(m2, Console.WindowWidth, Console.WindowHeight)
Console.WriteLine(m4)
Console.ReadKey(True)
'
' Step 3: Restore the window to its original size.
'
Console.SetWindowSize(origWidth, origHeight)
Console.WriteLine(m1, Console.WindowWidth, Console.WindowHeight)
End Sub
End Class
'
'This example produces the following results:
'
'The current window width is 85, and the current window height is 43.
' (Press any key to continue...)
'The new window width is 42, and the new window height is 21.
' (Press any key to continue...)
'The current window width is 85, and the current window height is 43.
'
'
적용 대상
.NET