VisualStyleRenderer 构造函数

定义

初始化 VisualStyleRenderer 类的新实例。Initializes a new instance of the VisualStyleRenderer class.

重载

VisualStyleRenderer(VisualStyleElement)

使用给定的 VisualStyleRenderer 初始化 VisualStyleElement 类的新实例。Initializes a new instance of the VisualStyleRenderer class using the given VisualStyleElement.

VisualStyleRenderer(String, Int32, Int32)

使用给定的类、部件和状态值初始化 VisualStyleRenderer 类的新实例。Initializes a new instance of the VisualStyleRenderer class using the given class, part, and state values.

VisualStyleRenderer(VisualStyleElement)

使用给定的 VisualStyleRenderer 初始化 VisualStyleElement 类的新实例。Initializes a new instance of the VisualStyleRenderer class using the given VisualStyleElement.

public:
 VisualStyleRenderer(System::Windows::Forms::VisualStyles::VisualStyleElement ^ element);
public VisualStyleRenderer (System.Windows.Forms.VisualStyles.VisualStyleElement element);
new System.Windows.Forms.VisualStyles.VisualStyleRenderer : System.Windows.Forms.VisualStyles.VisualStyleElement -> System.Windows.Forms.VisualStyles.VisualStyleRenderer
Public Sub New (element As VisualStyleElement)

参数

异常

操作系统不支持视觉样式。The operating system does not support visual styles.

-or-

用户在操作系统中禁用视觉样式。Visual styles are disabled by the user in the operating system.

-or-

视觉样式不应用于应用程序窗口的工作区。Visual styles are not applied to the client area of application windows.

当前视觉样式未定义 elementelement is not defined by the current visual style.

示例

下面的代码示例演示如何使用 VisualStyleRenderer(VisualStyleElement) 构造函数创建 VisualStyleRendererThe following code example demonstrates how to use the VisualStyleRenderer(VisualStyleElement) constructor to create a VisualStyleRenderer. 此代码示例摘自为 VisualStyleRenderer 类概述提供的更大的代码示例。This code example is part of a larger code example provided for the VisualStyleRenderer class overview.

    // Set the VisualStyleRenderer to a new element.
private:
    bool SetRenderer(VisualStyleElement^ element)
    {
        if (!VisualStyleRenderer::IsElementDefined(element))
        {
            return false;
        }

        if (renderer == nullptr)
        {
            renderer = gcnew VisualStyleRenderer(element);
        }
        else
        {
            renderer->SetParameters(element);
        }

        return true;
    }
// Set the VisualStyleRenderer to a new element.
private bool SetRenderer(VisualStyleElement element)
{
    if (!VisualStyleRenderer.IsElementDefined(element))
    {
        return false;
    }

    if (renderer == null)
    {
        renderer = new VisualStyleRenderer(element);
    }
    else
    {
        renderer.SetParameters(element);
    }

    return true;
}
' Set the VisualStyleRenderer to a new element.
Private Function SetRenderer(ByVal element As _
    VisualStyleElement) As Boolean

    If Not VisualStyleRenderer.IsElementDefined(element) Then
        Return False
    End If

    If renderer Is Nothing Then
        renderer = New VisualStyleRenderer(element)
    Else
        renderer.SetParameters(element)
    End If

    Return True
End Function

注解

此构造函数使用 element 参数的 VisualStyleElement.ClassNameVisualStyleElement.PartVisualStyleElement.State 属性来初始化 ClassPartState 属性。This constructor uses the VisualStyleElement.ClassName, VisualStyleElement.Part, and VisualStyleElement.State properties of the element parameter to initialize the Class, Part, and State properties.

使用此构造函数之前,应调用 staticIsElementDefined 方法,验证当前视觉样式是否为 element 参数指定的元素提供了定义。Before using this constructor, you should call the staticIsElementDefined method to verify whether the current visual style provides a definition for the element specified by the element parameter.

VisualStyleRenderer(String, Int32, Int32)

使用给定的类、部件和状态值初始化 VisualStyleRenderer 类的新实例。Initializes a new instance of the VisualStyleRenderer class using the given class, part, and state values.

public:
 VisualStyleRenderer(System::String ^ className, int part, int state);
public VisualStyleRenderer (string className, int part, int state);
new System.Windows.Forms.VisualStyles.VisualStyleRenderer : string * int * int -> System.Windows.Forms.VisualStyles.VisualStyleRenderer
Public Sub New (className As String, part As Integer, state As Integer)

参数

className
String

VisualStyleRenderer 将表示的元素的类名。The class name of the element that this VisualStyleRenderer will represent.

part
Int32

VisualStyleRenderer 将表示的元素的部件。The part of the element that this VisualStyleRenderer will represent.

state
Int32

VisualStyleRenderer 将表示的元素的状态。The state of the element that this VisualStyleRenderer will represent.

异常

操作系统不支持视觉样式。The operating system does not support visual styles.

-or-

用户在操作系统中禁用视觉样式。Visual styles are disabled by the user in the operating system.

-or-

视觉样式不应用于应用程序窗口的工作区。Visual styles are not applied to the client area of application windows.

当前视觉样式未定义 classNamepartstate 的组合。The combination of className, part, and state is not defined by the current visual style.

注解

此构造函数使用 classNamepartstate 参数来初始化 ClassPartState 属性。This constructor uses the className, part, and state parameters to initialize the Class, Part, and State properties.

使用此构造函数之前,应调用 staticIsElementDefined 方法,验证当前视觉样式是否为由 classNamepartstate 参数指定的元素提供了定义。Before using this constructor, you should call the staticIsElementDefined method to verify whether the current visual style provides a definition for the element specified by the className, part, and state parameters.

适用于