OSFeature.IsPresent(SystemParameter) 메서드

정의

운영 체제에서 지정된 기능 또는 메트릭을 지원하는지 여부를 나타내는 값을 검색합니다.

public:
 static bool IsPresent(System::Windows::Forms::SystemParameter enumVal);
public static bool IsPresent (System.Windows.Forms.SystemParameter enumVal);
static member IsPresent : System.Windows.Forms.SystemParameter -> bool
Public Shared Function IsPresent (enumVal As SystemParameter) As Boolean

매개 변수

enumVal
SystemParameter

검색할 기능을 나타내는 SystemParameter입니다.

반환

Boolean

시스템에서 해당 기능을 사용할 수 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 열거형을 IsPresent 사용 하 여 메서드를 SystemParameter 사용 하는 방법을 보여 줍니다. 이 예제에서는 속성을 호출 SystemInformation.CaretWidth 하기 전에 운영 체제에서 메트릭을 CaretWidth 지원하는지 여부를 확인합니다.

#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
// Gets the caret width based upon the operating system or default value.
int GetCaretWidth()
{
   // Check to see if the operating system supports the caret width metric. 
   if ( OSFeature::Feature->IsPresent( SystemParameter::CaretWidthMetric ) )
   {
      // If the operating system supports this metric,
      // return the value for the caret width metric. 
      return SystemInformation::CaretWidth;
   }
   else
         1;

   // If the operating system does not support this metric,
   // return a custom default value for the caret width.
}
// Gets the caret width based upon the operating system or default value.
private int GetCaretWidth ()
{    

    // Check to see if the operating system supports the caret width metric. 
    if (OSFeature.IsPresent(SystemParameter.CaretWidthMetric))
    {

        // If the operating system supports this metric,
        // return the value for the caret width metric. 

        return SystemInformation.CaretWidth;
    } else
    {

        // If the operating system does not support this metric,
        // return a custom default value for the caret width.

        return 1;
    }
}
' Gets the caret width based upon the operating system or default value.
Private Function GetCaretWidth() As Integer

    ' Check to see if the operating system supports the caret width metric. 
    If OSFeature.IsPresent(SystemParameter.CaretWidthMetric) Then

        ' If the operating system supports this metric,
        ' return the value for the caret width metric. 

        Return SystemInformation.CaretWidth
    Else

        ' If the operating system does not support this metric,
        ' return a custom default value for the caret width.

        Return 1
    End If
End Function

설명

일반적으로 이 메서드를 사용하여 운영 체제가 IsPresent 식별된 enumValue특정 기능 또는 메트릭을 지원하는지 확인합니다. 반환 IsPresent된 값에 따라 코드에서 조건부 작업을 수행합니다. 예를 들어, 매개 변수 값을 사용 하 여이 메서드를 호출 하는 경우 FlatMenu 반환 true, 평면 스타일의 애플리케이션에 소유자가 그린 메뉴를 만들 수 있습니다.

일부 시스템 기능 또는 메트릭에 액세스하면 특정 운영 체제 버전에서 사용할 수 없는 경우 예외가 발생합니다. 이 경우 먼저 해당 SystemParameter 열거형 값과 함께 IsPresent사용하여 메트릭이 지원되는지 확인합니다. 예를 들어 속성 값을 가져오기 전에 호출 IsPresent CaretWidth 합니다 SystemInformation.CaretWidth .

적용 대상

추가 정보