OSFeature.IsPresent(SystemParameter) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Haalt een waarde op die aangeeft of het besturingssysteem de opgegeven functie of metrische gegevens ondersteunt.
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
Parameters
- enumVal
- SystemParameter
Een SystemParameter weergave van de functie die moet worden gezocht.
Retouren
true als de functie beschikbaar is op het systeem; anders, false.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de IsPresent methode gebruikt met de SystemParameter opsomming. In het voorbeeld wordt bepaald of het besturingssysteem de CaretWidth metrische waarde ondersteunt voordat de SystemInformation.CaretWidth eigenschap wordt aangeroepen.
#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
Opmerkingen
Normaal gesproken gebruikt u de IsPresent methode om te bepalen of het besturingssysteem de specifieke functie of metrische gegevens ondersteunt die worden geïdentificeerd door enumValue. Op basis van de waarde die wordt geretourneerd, IsPresentvoert u voorwaardelijke acties uit in uw code. Als u deze methode bijvoorbeeld aanroept met een parameterwaarde van FlatMenu retourneert true, kunt u door de eigenaar getekende menu's in uw toepassing maken in een platte stijl.
Als u bepaalde systeemfuncties of metrische gegevens opent, kunnen er uitzonderingen optreden als deze niet beschikbaar zijn voor een specifieke versie van het besturingssysteem. In dit geval gebruikt u eerst de bijbehorende SystemParameter opsommingswaarde, samen met IsPresent, om te bepalen of de metrische waarde wordt ondersteund. Roep bijvoorbeeld IsPresent aan met CaretWidth voordat u de SystemInformation.CaretWidth eigenschapswaarde ophaalt.