VisualStyleRenderer VisualStyleRenderer VisualStyleRenderer VisualStyleRenderer Class

정의

VisualStyleElement를 그리고 관련 정보를 가져오는 메서드를 제공합니다.Provides methods for drawing and getting information about a VisualStyleElement. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.

public ref class VisualStyleRenderer sealed
public sealed class VisualStyleRenderer
type VisualStyleRenderer = class
Public NotInheritable Class VisualStyleRenderer
상속
VisualStyleRendererVisualStyleRendererVisualStyleRendererVisualStyleRenderer

예제

다음 코드 예제에서는 VisualStyleRenderer 창의 제목 표시줄을 사용 하 여 끌거나, 크기 조정 핸들을 사용 하 여 크기 조정, 닫는 등의 기본 UI의 일부를 시뮬레이션 하는 사용자 지정 컨트롤을 구현 하는 클래스입니다.The following code example uses the VisualStyleRenderer class to implement a custom control that simulates some of the basic UI of a window, including dragging with the title bar, resizing with the sizing handle, and closing. 이 예제에서는 여러 VisualStyleElement 창에서 노출 한 요소를 포함 하 여의 표준 부분을 나타내는 개체를 VisualStyleElement.Window.Caption, VisualStyleElement.Window.CloseButton, 및 VisualStyleElement.Status.Gripper 클래스입니다.This example uses several VisualStyleElement objects that represent standard parts of a window, including the elements exposed by the VisualStyleElement.Window.Caption, VisualStyleElement.Window.CloseButton, and VisualStyleElement.Status.Gripper classes.

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

using namespace System;
using namespace System::Text;
using namespace System::Drawing;
using namespace System::Drawing::Drawing2D;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::VisualStyles;

namespace VisualStyleRendererSample
{

    public ref class WindowSimulation : public Control
    {
    private:
        Dictionary<String^, VisualStyleElement^>^ windowElements;
        Dictionary<String^, Rectangle>^ elementRectangles;
        VisualStyleRenderer^ renderer;
        Point closeButtonOffset;
        System::Drawing::Size gripperSize;
        System::Drawing::Size closeButtonSize;
        bool isResizing;
        bool isMoving;
        bool isClosing;
        int captionHeight;
        int frameThickness;
        int statusHeight;
        Point originalClick;
        Point resizeOffset;

    public:
        WindowSimulation() : Control()
        {
            statusHeight = 22;
            windowElements = gcnew Dictionary<String^, VisualStyleElement^>();
            elementRectangles = gcnew Dictionary<String^, Rectangle>();
            this->Location = Point(50, 50);
            this->Size = System::Drawing::Size(350, 300);
            this->BackColor = Color::Azure;
            this->DoubleBuffered = true;
            this->MinimumSize = System::Drawing::Size(300, 200);
            this->Font = SystemFonts::CaptionFont;
            this->Text = "Simulated Window";

            // Insert the VisualStyleElement objects into the Dictionary.
            windowElements->Add("windowCaption",
                VisualStyleElement::Window::Caption::Active);
            windowElements->Add("windowBottom",
                VisualStyleElement::Window::FrameBottom::Active);
            windowElements->Add("windowLeft",
                VisualStyleElement::Window::FrameLeft::Active);
            windowElements->Add("windowRight",
                VisualStyleElement::Window::FrameRight::Active);
            windowElements->Add("windowClose",
                VisualStyleElement::Window::CloseButton::Normal);
            windowElements->Add("statusBar",
                VisualStyleElement::Status::Bar::Normal);
            windowElements->Add("statusGripper",
                VisualStyleElement::Status::Gripper::Normal);

            // Get the sizes and location offsets for the window parts
            // as specified by the visual style, and then use this
            // information to calcualate the rectangles for each part.
            GetPartDetails();
            CalculateRectangles();

            this->MouseDown +=
                gcnew MouseEventHandler(this,
                    &WindowSimulation::ImitationWindow_MouseDown);
            this->MouseUp +=
                gcnew MouseEventHandler(this,
                    &WindowSimulation::ImitationWindow_MouseUp);
            this->MouseMove +=
                gcnew MouseEventHandler(this,
                    &WindowSimulation::ImitationWindow_MouseMove);
        }

        // Get the sizes and offsets for the window parts as specified
        // by the visual style.
    private:
        void GetPartDetails()
        {
            // Do nothing further if visual styles are not enabled.
            if (!Application::RenderWithVisualStyles)
            {
                return;
            }

            Graphics^ g = this->CreateGraphics();

            // Get the size and offset of the close button.
            if (SetRenderer(windowElements["windowClose"]))
            {
                closeButtonSize =
                    renderer->GetPartSize(g, ThemeSizeType::True);
                closeButtonOffset =
                    renderer->GetPoint(PointProperty::Offset);
            }

            // Get the height of the window caption.
            if (SetRenderer(windowElements["windowCaption"]))
            {
                captionHeight = renderer->GetPartSize(g,
                    ThemeSizeType::True).Height;
            }

            // Get the thickness of the left, bottom,
            // and right window frame.
            if (SetRenderer(windowElements["windowLeft"]))
            {
                frameThickness = renderer->GetPartSize(g,
                    ThemeSizeType::True).Width;
            }

            // Get the size of the resizing gripper.
            if (SetRenderer(windowElements["statusGripper"]))
            {
                gripperSize = renderer->GetPartSize(g,
                    ThemeSizeType::True);
            }

        }

        // Use the part metrics to determine the current size
        // of the rectangles for all of the window parts.
    private:
        void CalculateRectangles()
        {
            int heightMinusFrame =
                ClientRectangle.Height - frameThickness;

            // Calculate the window frame rectangles and add them
            // to the Dictionary of rectangles.
            elementRectangles["windowCaption"] = Rectangle(0, 0,
                ClientRectangle.Width, captionHeight);
            elementRectangles["windowBottom"] = Rectangle(0,
                heightMinusFrame, ClientRectangle.Width, frameThickness);
            elementRectangles["windowLeft"] = Rectangle(0, captionHeight,
                frameThickness, heightMinusFrame - captionHeight);
            elementRectangles["windowRight"] = Rectangle(
                ClientRectangle.Width - frameThickness, captionHeight,
                frameThickness, heightMinusFrame - captionHeight);

            // Calculate the window button rectangle and add it
            // to the Dictionary of rectangles.
            elementRectangles["windowClose"] =
                Rectangle(ClientRectangle.Right +
                    closeButtonOffset.X, closeButtonOffset.Y,
                    closeButtonSize.Width, closeButtonSize.Height);

            // Calculate the status bar rectangles and add them
            // to the Dictionary of rectangles.
            elementRectangles["statusBar"] =
                Rectangle(frameThickness,
                    heightMinusFrame - statusHeight,
                    ClientRectangle.Width - (2 * frameThickness),
                    statusHeight);
            elementRectangles["statusGripper"] =
                Rectangle(ClientRectangle.Right -
                gripperSize.Width - frameThickness,
                heightMinusFrame - gripperSize.Height,
                gripperSize.Width, gripperSize.Height);
        }

    protected:
        virtual void OnPaint(PaintEventArgs^ e) override
        {
            __super::OnPaint(e);

            // Ensure that visual styles are supported.
            if (!Application::RenderWithVisualStyles)
            {
                this->Text = "Visual styles are not enabled.";
                TextRenderer::DrawText(e->Graphics, this->Text,
                    this->Font, this->Location, this->ForeColor);
                return;
            }

            // Set the clip region to define the curved corners
            // of the caption.
            SetClipRegion();

            // Draw each part of the window.
            for each(KeyValuePair<String^, VisualStyleElement^>^ entry
                in windowElements)
            {
                if (SetRenderer(entry->Value))
                {
                    renderer->DrawBackground(e->Graphics,
                        elementRectangles[entry->Key]);
                }
            }

            // Draw the caption text.
            TextRenderer::DrawText(e->Graphics, this->Text, this->Font,
                elementRectangles["windowCaption"], Color::White,
                TextFormatFlags::VerticalCenter |
                TextFormatFlags::HorizontalCenter);
        }
private:
        // Initiate dragging, resizing, or closing the imitation window.
        void ImitationWindow_MouseDown(Object^ sender, MouseEventArgs^ e)
        {
            // The user clicked the close button.
            if (elementRectangles["windowClose"].Contains(e->Location))
            {
                windowElements["windowClose"] =
                    VisualStyleElement::Window::CloseButton::Pressed;
                isClosing = true;
            }

            // The user clicked the status grip.
            else if (elementRectangles["statusGripper"].Contains(e->Location))
            {
                isResizing = true;
                this->Cursor = Cursors::SizeNWSE;
                resizeOffset.X = this->Right - this->Left - e->X;
                resizeOffset.Y = this->Bottom - this->Top - e->Y;
            }

            // The user clicked the window caption.
            else if (elementRectangles["windowCaption"].Contains(e->Location))
            {
                isMoving = true;
                originalClick.X = e->X;
                originalClick.Y = e->Y;
            }

            Invalidate();
        }

        // Stop any current resizing or moving actions.
        void ImitationWindow_MouseUp(Object^ sender, MouseEventArgs^ e)
        {
            // Stop moving the location of the window rectangles.
            if (isMoving)
            {
                isMoving = false;
            }

            // Change the cursor back to the default if the user
            // stops resizing.
            else if (isResizing)
            {
                isResizing = false;
            }

            // Close the application if the user clicks the
            // close button.
            else if (elementRectangles["windowClose"].Contains(e->Location) 
                && isClosing)
            {
                Application::Exit();
            }
        }

        // Handle resizing or moving actions.
        void ImitationWindow_MouseMove(Object^ sender,
            MouseEventArgs^ e)
        {
            // The left mouse button is down.
            if ((::MouseButtons::Left & e->Button) == ::MouseButtons::Left)
            {
                // Calculate the new control size if the user is
                // dragging the resizing grip.
                if (isResizing)
                {
                    this->Width = e->X + resizeOffset.X;
                    this->Height = e->Y + resizeOffset.Y;
                    CalculateRectangles();
                }

                // Calculate the new location of the control if the
                // user is dragging the window caption.
                else if (isMoving)
                {
                    int XChange = this->Location.X + (e->X - originalClick.X);
                    int YChange = this->Location.Y + (e->Y - originalClick.Y);
                    this->Location = Point(XChange, YChange);
                }

                // Cancel the closing action if the user clicked
                // and held down on the close button, and has dragged
                // the pointer outside the button.
                else if (!elementRectangles["windowClose"].Contains(
                    e->Location) && isClosing)
                {
                    isClosing = false;
                    windowElements["windowClose"] =
                        VisualStyleElement::Window::CloseButton::Normal;
                }
            }

            // The left mouse button is not down.
            else
            {
                // Paint the close button hot if the cursor is on it.
                Rectangle^ closeRectangle =
                    elementRectangles["windowClose"];
                if (closeRectangle->Contains(e->Location))
                {
                    windowElements["windowClose"] =
                        VisualStyleElement::Window::CloseButton::Hot;
                }
                else
                {
                    windowElements["windowClose"] =
                        VisualStyleElement::Window::CloseButton::Normal;
                }


                // Use a resizing cursor if the cursor is on the
                // status grip.
                Rectangle^ gripRectangle = elementRectangles["statusGripper"];
                if (gripRectangle->Contains(e->Location))
                {
                    this->Cursor = Cursors::SizeNWSE;
                }
                else
                {
                    this->Cursor = Cursors::Default;
                }
            }

            Invalidate();
        }

        // Calculate and set the clipping region for the control
        // so that the corners of the title bar are rounded.
    private:
        void SetClipRegion()
        {
            if (!Application::RenderWithVisualStyles)
            {
                return;
            }

            Graphics^ g = this->CreateGraphics();
            // Get the current region for the window caption.
            if (SetRenderer(windowElements["windowCaption"]))
            {
                System::Drawing::Region^ clipRegion =
                    renderer->GetBackgroundRegion(g,
                    elementRectangles["windowCaption"]);

                // Get the client rectangle, but exclude the region
                // of the window caption.
                int height = (int)clipRegion->GetBounds(g).Height;
                System::Drawing::Rectangle nonCaptionRect = Rectangle(
                    ClientRectangle.X, ClientRectangle.Y + height,
                    ClientRectangle.Width, ClientRectangle.Height - height);

                // Add the rectangle to the caption region, and
                // make this region the form's clipping region.
                clipRegion->Union(nonCaptionRect);
                this->Region = clipRegion;
            }

        }

        // 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;
        }
    };

    public ref class Form1 : public Form
    {
    public:
        Form1() : Form()
        {
            this->Size = System::Drawing::Size(800, 600);
            this->Location = Point(20, 20);
            this->BackColor = Color::DarkGray;
            WindowSimulation^ ws = gcnew WindowSimulation();
            Controls->Add(ws);
        }

    };
}

[STAThread]
int main()
{
    Application::EnableVisualStyles();
    Application::Run(gcnew VisualStyleRendererSample::Form1());
}
using System;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace VisualStyleRendererSample
{
    class Form1 : Form
    {
        public Form1()
            : base()
        {
            this.Size = new Size(800, 600);
            this.Location = new Point(20, 20);
            this.BackColor = Color.DarkGray;
            WindowSimulation Window1 = new WindowSimulation();
            Controls.Add(Window1);
        }

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }
    }

    public class WindowSimulation : Control
    {
        private Dictionary<string, VisualStyleElement> windowElements =
            new Dictionary<string, VisualStyleElement>();
        private Dictionary<string, Rectangle> elementRectangles =
            new Dictionary<string, Rectangle>();
        private VisualStyleRenderer renderer = null;

        private Point closeButtonOffset;
        private Size gripperSize;
        private Size closeButtonSize;
        private bool isResizing = false;
        private bool isMoving = false;
        private bool isClosing = false;
        private int captionHeight;
        private int frameThickness;
        private int statusHeight = 22;
        private Point originalClick = new Point();
        private Point resizeOffset = new Point();

        public WindowSimulation()
            : base()
        {
            this.Location = new Point(50, 50);
            this.Size = new Size(350, 300);
            this.BackColor = Color.Azure;
            this.DoubleBuffered = true;
            this.MinimumSize = new Size(300, 200);
            this.Font = SystemFonts.CaptionFont;
            this.Text = "Simulated Window";

            // Insert the VisualStyleElement objects into the Dictionary.
            windowElements.Add("windowCaption",
                VisualStyleElement.Window.Caption.Active);
            windowElements.Add("windowBottom",
                VisualStyleElement.Window.FrameBottom.Active);
            windowElements.Add("windowLeft",
                VisualStyleElement.Window.FrameLeft.Active);
            windowElements.Add("windowRight",
                VisualStyleElement.Window.FrameRight.Active);
            windowElements.Add("windowClose",
                VisualStyleElement.Window.CloseButton.Normal);
            windowElements.Add("statusBar",
                VisualStyleElement.Status.Bar.Normal);
            windowElements.Add("statusGripper",
                VisualStyleElement.Status.Gripper.Normal);

            // Get the sizes and location offsets for the window parts  
            // as specified by the visual style, and then use this 
            // information to calcualate the rectangles for each part.
            GetPartDetails();
            CalculateRectangles();

            this.MouseDown +=
                new MouseEventHandler(ImitationWindow_MouseDown);
            this.MouseUp +=
                new MouseEventHandler(ImitationWindow_MouseUp);
            this.MouseMove +=
                new MouseEventHandler(ImitationWindow_MouseMove);
        }

        // Get the sizes and offsets for the window parts as specified  
        // by the visual style.
        private void GetPartDetails()
        {
            // Do nothing further if visual styles are not enabled.
            if (!Application.RenderWithVisualStyles)
            {
                return;
            }

            using (Graphics g = this.CreateGraphics())
            {
                // Get the size and offset of the close button.
                if (SetRenderer(windowElements["windowClose"]))
                {
                    closeButtonSize =
                        renderer.GetPartSize(g, ThemeSizeType.True);
                    closeButtonOffset =
                        renderer.GetPoint(PointProperty.Offset);
                }

                // Get the height of the window caption.
                if (SetRenderer(windowElements["windowCaption"]))
                {
                    captionHeight = renderer.GetPartSize(g,
                        ThemeSizeType.True).Height;
                }

                // Get the thickness of the left, bottom, 
                // and right window frame.
                if (SetRenderer(windowElements["windowLeft"]))
                {
                    frameThickness = renderer.GetPartSize(g,
                        ThemeSizeType.True).Width;
                }

                // Get the size of the resizing gripper.
                if (SetRenderer(windowElements["statusGripper"]))
                {
                    gripperSize = renderer.GetPartSize(g,
                        ThemeSizeType.True);
                }
            }
        }

        // Use the part metrics to determine the current size 
        // of the rectangles for all of the window parts.
        private void CalculateRectangles()
        {
            int heightMinusFrame =
                ClientRectangle.Height - frameThickness;

            // Calculate the window frame rectangles and add them
            // to the Dictionary of rectangles.
            elementRectangles["windowCaption"] =
                new Rectangle(0, 0,
                ClientRectangle.Width, captionHeight);
            elementRectangles["windowBottom"] =
                new Rectangle(0, heightMinusFrame,
                ClientRectangle.Width, frameThickness);
            elementRectangles["windowLeft"] =
                new Rectangle(0, captionHeight, frameThickness,
                heightMinusFrame - captionHeight);
            elementRectangles["windowRight"] =
                new Rectangle(ClientRectangle.Width - frameThickness,
                captionHeight, frameThickness,
                heightMinusFrame - captionHeight);

            // Calculate the window button rectangle and add it
            // to the Dictionary of rectangles.
            elementRectangles["windowClose"] =
                new Rectangle(ClientRectangle.Right +
                closeButtonOffset.X, closeButtonOffset.Y,
                closeButtonSize.Width, closeButtonSize.Height);

            // Calculate the status bar rectangles and add them
            // to the Dictionary of rectangles.
            elementRectangles["statusBar"] =
                new Rectangle(frameThickness,
                heightMinusFrame - statusHeight,
                ClientRectangle.Width - (2 * frameThickness),
                statusHeight);
            elementRectangles["statusGripper"] =
                new Rectangle(ClientRectangle.Right -
                gripperSize.Width - frameThickness,
                heightMinusFrame - gripperSize.Height,
                gripperSize.Width, gripperSize.Height);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Ensure that visual styles are supported.
            if (!Application.RenderWithVisualStyles)
            {
                this.Text = "Visual styles are not enabled.";
                TextRenderer.DrawText(e.Graphics, this.Text,
                    this.Font, this.Location, this.ForeColor);
                return;
            }

            // Set the clip region to define the curved corners 
            // of the caption.
            SetClipRegion();

            // Draw each part of the window.
            foreach (KeyValuePair<string, VisualStyleElement> entry
                in windowElements)
            {
                if (SetRenderer(entry.Value))
                {
                    renderer.DrawBackground(e.Graphics,
                        elementRectangles[entry.Key]);
                }
            }

            // Draw the caption text.
            TextRenderer.DrawText(e.Graphics, this.Text, this.Font,
                elementRectangles["windowCaption"], Color.White,
                TextFormatFlags.VerticalCenter |
                TextFormatFlags.HorizontalCenter);
        }

        // Initiate dragging, resizing, or closing the imitation window.
        void ImitationWindow_MouseDown(object sender, MouseEventArgs e)
        {
            // The user clicked the close button.
            if (elementRectangles["windowClose"].Contains(e.Location))
            {
                windowElements["windowClose"] =
                    VisualStyleElement.Window.CloseButton.Pressed;
                isClosing = true;
            }

            // The user clicked the status grip.
            else if (elementRectangles["statusGripper"].
                Contains(e.Location))
            {
                isResizing = true;
                this.Cursor = Cursors.SizeNWSE;
                resizeOffset.X = this.Right - this.Left - e.X;
                resizeOffset.Y = this.Bottom - this.Top - e.Y;
            }

            // The user clicked the window caption.
            else if (elementRectangles["windowCaption"].
                Contains(e.Location))
            {
                isMoving = true;
                originalClick.X = e.X;
                originalClick.Y = e.Y;
            }

            Invalidate();
        }

        // Stop any current resizing or moving actions.
        void ImitationWindow_MouseUp(object sender, MouseEventArgs e)
        {
            // Stop moving the location of the window rectangles.
            if (isMoving)
            {
                isMoving = false;
            }

            // Change the cursor back to the default if the user 
            // stops resizing.
            else if (isResizing)
            {
                isResizing = false;
            }

            // Close the application if the user clicks the 
            // close button.
            else if (elementRectangles["windowClose"].
                Contains(e.Location) && isClosing)
            {
                Application.Exit();
            }
        }

        // Handle resizing or moving actions.
        void ImitationWindow_MouseMove(object sender,
            MouseEventArgs e)
        {
            // The left mouse button is down.
            if ((MouseButtons.Left & e.Button) == MouseButtons.Left)
            {
                // Calculate the new control size if the user is 
                // dragging the resizing grip.
                if (isResizing)
                {
                    this.Width = e.X + resizeOffset.X;
                    this.Height = e.Y + resizeOffset.Y;
                    CalculateRectangles();
                }

                // Calculate the new location of the control if the  
                // user is dragging the window caption.
                else if (isMoving)
                {
                    int XChange = this.Location.X +
                        (e.X - originalClick.X);
                    int YChange = this.Location.Y +
                        (e.Y - originalClick.Y);
                    this.Location = new Point(XChange, YChange);
                }

                // Cancel the closing action if the user clicked  
                // and held down on the close button, and has dragged   
                // the pointer outside the button.
                else if (!elementRectangles["windowClose"].
                    Contains(e.Location) && isClosing)
                {
                    isClosing = false;
                    windowElements["windowClose"] =
                        VisualStyleElement.Window.CloseButton.Normal;
                }
            }

            // The left mouse button is not down.
            else
            {
                // Paint the close button hot if the cursor is on it.
                Rectangle closeRectangle =
                    elementRectangles["windowClose"];
                windowElements["windowClose"] =
                    closeRectangle.Contains(e.Location) ?
                    VisualStyleElement.Window.CloseButton.Hot :
                    VisualStyleElement.Window.CloseButton.Normal;

                // Use a resizing cursor if the cursor is on the 
                // status grip.
                Rectangle gripRectangle =
                    elementRectangles["statusGripper"];
                this.Cursor = gripRectangle.Contains(e.Location) ?
                    Cursors.SizeNWSE : Cursors.Default;
            }

            Invalidate();
        }

        // Calculate and set the clipping region for the control  
        // so that the corners of the title bar are rounded.
        private void SetClipRegion()
        {
            if (!Application.RenderWithVisualStyles)
            {
                return;
            }

            using (Graphics g = this.CreateGraphics())
            {
                // Get the current region for the window caption.
                if (SetRenderer(windowElements["windowCaption"]))
                {
                    Region clipRegion = renderer.GetBackgroundRegion(
                        g, elementRectangles["windowCaption"]);

                    // Get the client rectangle, but exclude the region 
                    // of the window caption.
                    int height = (int)clipRegion.GetBounds(g).Height;
                    Rectangle nonCaptionRect = new Rectangle(
                        ClientRectangle.X,
                        ClientRectangle.Y + height,
                        ClientRectangle.Width,
                        ClientRectangle.Height - height);

                    // Add the rectangle to the caption region, and  
                    // make this region the form's clipping region.
                    clipRegion.Union(nonCaptionRect);
                    this.Region = clipRegion;
                }
            }
        }

        // 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;
        }
    }
}
Imports System.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles

Namespace VisualStyleRendererSample

    Class Form1
        Inherits Form

        Public Sub New()
            With Me
                .Size = New Size(800, 600)
                .Location = New Point(20, 20)
                .BackColor = Color.DarkGray
            End With
            Dim Window1 As New ImitationWindow()
            Controls.Add(Window1)
        End Sub

        <STAThread()> _
        Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New Form1())
        End Sub
    End Class

    Public Class ImitationWindow
        Inherits Control

        Private windowElements As _
            New Dictionary(Of String, VisualStyleElement)
        Private elementRectangles As _
            New Dictionary(Of String, Rectangle)
        Private renderer As VisualStyleRenderer = Nothing
        Private closeButtonOffset As Point
        Private gripperSize As Size
        Private closeButtonSize As Size
        Private isResizing As Boolean = False
        Private isMoving As Boolean = False
        Private isClosing As Boolean = False
        Private captionHeight As Integer
        Private frameThickness As Integer
        Private statusHeight As Integer = 22
        Private originalClick As New Point()
        Private resizeOffset As New Point()

        Public Sub New()
            With Me
                .Location = New Point(50, 50)
                .Size = New Size(350, 300)
                .BackColor = Color.Azure
                .DoubleBuffered = True
                .MinimumSize = New Size(300, 200)
                .Font = SystemFonts.CaptionFont
                .Text = "Imitation Window"
            End With

            ' Create a collection of VisualStyleElement objects.
            With windowElements
                .Add("windowCaption", _
                    VisualStyleElement.Window.Caption.Active)
                .Add("windowBottom", _
                    VisualStyleElement.Window.FrameBottom.Active)
                .Add("windowLeft", _
                    VisualStyleElement.Window.FrameLeft.Active)
                .Add("windowRight", _
                    VisualStyleElement.Window.FrameRight.Active)
                .Add("windowClose", _
                    VisualStyleElement.Window.CloseButton.Normal)
                .Add("statusBar", _
                    VisualStyleElement.Status.Bar.Normal)
                .Add("statusGripper", _
                    VisualStyleElement.Status.Gripper.Normal)
            End With

            ' Get the sizes and location offsets for the window parts  
            ' as specified by the visual style, and then use this   
            ' information to calcualate the rectangles for each part.
            GetPartDetails()
            CalculateRectangles()
        End Sub

        ' Get the sizes and offsets for the window parts as specified 
        ' by the visual style.
        Private Sub GetPartDetails()
            ' Do nothing further if visual styles are not enabled.
            If Not Application.RenderWithVisualStyles Then
                Return
            End If

            Using g As Graphics = Me.CreateGraphics()
                ' Get the size and offset of the close button.
                If SetRenderer(windowElements("windowClose")) Then
                    closeButtonSize = _
                        renderer.GetPartSize(g, ThemeSizeType.True)
                    closeButtonOffset = _
                        renderer.GetPoint(PointProperty.Offset)
                End If

                ' Get the height of the window caption.
                If SetRenderer(windowElements("windowCaption")) Then
                    captionHeight = renderer.GetPartSize(g, _
                        ThemeSizeType.True).Height
                End If

                ' Get the thickness of the left, bottom, and right 
                ' window frame.
                If SetRenderer(windowElements("windowLeft")) Then
                    frameThickness = renderer.GetPartSize(g, _
                        ThemeSizeType.True).Width
                End If

                ' Get the size of the resizing gripper.
                If SetRenderer(windowElements("statusGripper")) Then
                    gripperSize = renderer.GetPartSize(g, _
                        ThemeSizeType.True)
                End If
            End Using
        End Sub

        ' Use the part metrics to determine the current size of the 
        ' rectangles for all of the window parts.
        Private Sub CalculateRectangles()

            Dim heightMinusFrame As Integer = _
                ClientRectangle.Height - frameThickness

            ' Calculate the window frame rectangles and add them
            ' to the Dictionary of rectangles.
            elementRectangles("windowCaption") = _
                New Rectangle(0, 0, ClientRectangle.Width, _
                captionHeight)
            elementRectangles("windowBottom") = _
                New Rectangle(0, heightMinusFrame, _
                ClientRectangle.Width, frameThickness)
            elementRectangles("windowLeft") = _
                New Rectangle(0, captionHeight, frameThickness, _
                heightMinusFrame - captionHeight)
            elementRectangles("windowRight") = _
                New Rectangle(ClientRectangle.Width - frameThickness, _
                captionHeight, frameThickness, _
                heightMinusFrame - captionHeight)

            ' Calculate the window button rectangle and add it
            ' to the Dictionary of rectangles.
            elementRectangles("windowClose") = _
                New Rectangle(ClientRectangle.Right + _
                closeButtonOffset.X, closeButtonOffset.Y, _
                closeButtonSize.Width, closeButtonSize.Height)

            ' Calculate the status bar rectangles and add them
            ' to the Dictionary of rectangles.
            elementRectangles("statusBar") = _
                New Rectangle(frameThickness, _
                heightMinusFrame - statusHeight, _
                ClientRectangle.Width - 2 * frameThickness, _
                statusHeight)
            elementRectangles("statusGripper") = _
                New Rectangle(ClientRectangle.Right - _
                gripperSize.Width - frameThickness, _
                heightMinusFrame - gripperSize.Height, _
                gripperSize.Width, gripperSize.Height)
        End Sub

        Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
            MyBase.OnPaint(e)

            ' Ensure that visual styles are supported.
            If Not Application.RenderWithVisualStyles Then
                Me.Text = "Visual styles are not enabled."
                TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, _
                    Me.Location, Me.ForeColor)
                Return
            End If

            ' Set the clip region to define the curved corners of 
            ' the caption.
            SetClipRegion()

            ' Draw each part of the window.
            Dim entry As KeyValuePair(Of String, VisualStyleElement)
            For Each entry In windowElements
                If SetRenderer(entry.Value) Then
                    renderer.DrawBackground(e.Graphics, _
                        elementRectangles(entry.Key))
                End If
            Next entry

            ' Draw the caption text.
            TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, _
                elementRectangles("windowCaption"), Color.White, _
                TextFormatFlags.VerticalCenter Or _
                TextFormatFlags.HorizontalCenter)
        End Sub

        ' Initiate dragging, resizing, or closing the imitation window.
        Private Sub ImitationWindow_MouseDown(ByVal sender As Object, _
            ByVal e As MouseEventArgs) Handles Me.MouseDown

            ' The user clicked the close button.
            If elementRectangles("windowClose"). _
                Contains(e.Location) Then

                windowElements("windowClose") = _
                    VisualStyleElement.Window.CloseButton.Pressed
                isClosing = True

            ' The user clicked the status grip.
            ElseIf elementRectangles("statusGripper"). _
                Contains(e.Location) Then

                isResizing = True
                Me.Cursor = Cursors.SizeNWSE
                resizeOffset.X = Me.Right - Me.Left - e.X
                resizeOffset.Y = Me.Bottom - Me.Top - e.Y

            ' The user clicked the window caption.
            ElseIf elementRectangles("windowCaption"). _
                Contains(e.Location) Then

                isMoving = True
                originalClick.X = e.X
                originalClick.Y = e.Y
            End If
            Invalidate()
        End Sub

        ' Stop any current resizing or moving actions.
        Private Sub ImitationWindow_MouseUp(ByVal sender As Object, _
            ByVal e As MouseEventArgs) Handles Me.MouseUp

            ' Stop moving the location of the window rectangles.
            If isMoving Then
                isMoving = False

            ' Change the cursor back to the default if the 
            ' user stops resizing.
            ElseIf isResizing Then
                isResizing = False

            ' Close the application if the user clicks the 
            ' close button.
            ElseIf elementRectangles("windowClose"). _
                Contains(e.Location) And isClosing Then
                Application.Exit()
            End If
        End Sub

        ' Handle resizing or moving actions.
        Private Sub ImitationWindow_MouseMove(ByVal sender As Object, _
            ByVal e As MouseEventArgs) Handles Me.MouseMove

            ' The left mouse button is down.
            If (MouseButtons.Left And e.Button) = _
                MouseButtons.Left Then

                ' Calculate the new control size if the user is  
                ' dragging the resizing grip.
                If isResizing Then
                    Me.Width = e.X + resizeOffset.X
                    Me.Height = e.Y + resizeOffset.Y
                    CalculateRectangles()

                ' Calculate the new location of the control if   
                ' the user is dragging the window caption.
                ElseIf isMoving Then
                    Dim XChange As Integer = Me.Location.X + _
                        (e.X - originalClick.X)
                    Dim YChange As Integer = Me.Location.Y + _
                        (e.Y - originalClick.Y)
                    Me.Location = New Point(XChange, YChange)

                ' Cancel the closing action if the user clicked and  
                ' held down on the close button, and has dragged the   
                ' pointer outside the button.
                ElseIf Not elementRectangles("windowClose"). _
                    Contains(e.Location) And isClosing Then

                    isClosing = False
                    windowElements("windowClose") = _
                        VisualStyleElement.Window.CloseButton.Normal
                End If

            ' The left mouse button is not down.
            Else
                ' Paint the close button hot if the cursor is on it.
                If elementRectangles("windowClose"). _
                    Contains(e.Location) Then
                    windowElements("windowClose") = _
                        VisualStyleElement.Window.CloseButton.Hot
                Else
                    windowElements("windowClose") = _
                        VisualStyleElement.Window.CloseButton.Normal
                End If

                ' Use a resizing cursor if the cursor is on the 
                ' status grip.
                If elementRectangles("statusGripper"). _
                    Contains(e.Location) Then
                    Me.Cursor = Cursors.SizeNWSE
                Else
                    Me.Cursor = Cursors.Default
                End If
            End If
            Invalidate()
        End Sub

        ' Calculate and set the clipping region for the control  
        ' so that the corners of the title bar are rounded.
        Private Sub SetClipRegion()
            If Not Application.RenderWithVisualStyles Then
                Return
            End If

            Using g As Graphics = Me.CreateGraphics()
                ' Get the current region for the window caption.
                If SetRenderer(windowElements("windowCaption")) Then
                    Dim clipRegion As Region = _
                        renderer.GetBackgroundRegion(g, _
                        elementRectangles("windowCaption"))

                    ' Get the client rectangle, but exclude the   
                    ' region of the window caption.
                    Dim height As Integer = _
                        CInt(clipRegion.GetBounds(g).Height)
                    Dim nonCaptionRect As _
                        New Rectangle(ClientRectangle.X, _
                        ClientRectangle.Y + height, _
                        ClientRectangle.Width, _
                        ClientRectangle.Height - height)

                    ' Add the rectangle to the caption region, and  
                    ' make this region the form's clipping region.
                    clipRegion.Union(nonCaptionRect)
                    Me.Region = clipRegion
                End If
            End Using
        End Sub

        ' 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

    End Class
End Namespace

설명

합니다 System.Windows.Forms.VisualStyles 네임 스페이스는 VisualStyleElement 모든 컨트롤 및 사용자를 나타내는 개체 인터페이스 (UI) 요소 비주얼 스타일에서 지원 되는 합니다.The System.Windows.Forms.VisualStyles namespace exposes VisualStyleElement objects that represent all of the controls and user interface (UI) elements that are supported by visual styles. 그리기 또는 특정 요소에 대 한 정보를 설정 해야 합니다는 VisualStyleRenderer 관심 요소입니다.To draw or get information about a particular element, you must set a VisualStyleRenderer to the element you are interested in. VisualStyleRenderer 지정 된 자동으로 설정 됩니다 VisualStyleElementVisualStyleRenderer 생성자도 설정할 수 있는 기존 VisualStyleRenderer 호출 하 여 다른 요소에는 SetParameters 메서드.A VisualStyleRenderer is automatically set to a specified VisualStyleElement in the VisualStyleRenderer constructor, but you can also set an existing VisualStyleRenderer to a different element by calling the SetParameters method.

요소를 그리려면, 사용 된 DrawBackground 메서드.To draw an element, use the DrawBackground method. 합니다 VisualStyleRenderer 클래스도 포함 되어 있습니다 메서드 같은 GetColorGetEnumValue, 요소는 현재 비주얼 스타일에 정의한 방법에 대 한 정보를 제공 하는 합니다.The VisualStyleRenderer class also includes methods, such as GetColor and GetEnumValue, that provide information about how an element is defined by the current visual style.

VisualStyleRenderer 생성자와 많은 VisualStyleRenderer 메서드는 운영 체제에서 비주얼 스타일을 사용 하 고 애플리케이션 창의 클라이언트 영역에 비주얼 스타일을 적용 하지 않으면 예외를 throw 합니다.The VisualStyleRenderer constructor and many of the VisualStyleRenderer methods throw exceptions unless visual styles are enabled in the operating system and visual styles are applied to the client area of application windows. 이러한 조건을 확인 하려면 사용 합니다 static IsSupported 속성입니다.To check for these conditions, use the staticIsSupported property.

VisualStyleRenderer 클래스는 비주얼 스타일 (UxTheme) API는 Windows Platform SDK의 Windows 셸 부분에서의 기능을 래핑합니다.The VisualStyleRenderer class wraps the functionality of the visual styles (UxTheme) API from the Windows Shell portion of the Windows Platform SDK.

생성자

VisualStyleRenderer(String, Int32, Int32) VisualStyleRenderer(String, Int32, Int32) VisualStyleRenderer(String, Int32, Int32) 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) VisualStyleRenderer(VisualStyleElement) VisualStyleRenderer(VisualStyleElement)

지정된 VisualStyleRenderer을 사용하여 VisualStyleElement 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the VisualStyleRenderer class using the given VisualStyleElement.

속성

Class Class Class Class

현재 비주얼 스타일 요소의 클래스 이름을 가져옵니다.Gets the class name of the current visual style element.

Handle Handle Handle Handle

비주얼 스타일 요소의 현재 클래스에 대한 고유 식별자를 가져옵니다.Gets a unique identifier for the current class of visual style elements.

IsSupported IsSupported IsSupported IsSupported

운영 체제에서 컨트롤을 그리기 위해 비주얼 스타일을 사용하는지 여부를 지정하는 값을 가져옵니다.Gets a value specifying whether the operating system is using visual styles to draw controls.

LastHResult LastHResult LastHResult LastHResult

VisualStyleRenderer 클래스로 캡슐화된 네이티브 비주얼 스타일(UxTheme) API 메서드에서 반환한 마지막 오류 코드를 가져옵니다.Gets the last error code returned by the native visual styles (UxTheme) API methods encapsulated by the VisualStyleRenderer class.

Part Part Part Part

현재 비주얼 스타일 요소의 파트를 가져옵니다.Gets the part of the current visual style element.

State State State State

현재 비주얼 스타일 요소의 상태를 가져옵니다.Gets the state of the current visual style element.

메서드

DrawBackground(IDeviceContext, Rectangle) DrawBackground(IDeviceContext, Rectangle) DrawBackground(IDeviceContext, Rectangle) DrawBackground(IDeviceContext, Rectangle)

지정된 경계 사각형 내에 현재 비주얼 스타일 요소의 배경 이미지를 그립니다.Draws the background image of the current visual style element within the specified bounding rectangle.

DrawBackground(IDeviceContext, Rectangle, Rectangle) DrawBackground(IDeviceContext, Rectangle, Rectangle) DrawBackground(IDeviceContext, Rectangle, Rectangle) DrawBackground(IDeviceContext, Rectangle, Rectangle)

지정된 경계 사각형 내에 지정된 클리핑 사각형으로 클리핑하여 현재 비주얼 스타일 요소의 배경 이미지를 그립니다.Draws the background image of the current visual style element within the specified bounding rectangle and clipped to the specified clipping rectangle.

DrawEdge(IDeviceContext, Rectangle, Edges, EdgeStyle, EdgeEffects) DrawEdge(IDeviceContext, Rectangle, Edges, EdgeStyle, EdgeEffects) DrawEdge(IDeviceContext, Rectangle, Edges, EdgeStyle, EdgeEffects) DrawEdge(IDeviceContext, Rectangle, Edges, EdgeStyle, EdgeEffects)

지정된 경계 사각형의 하나 이상의 가장자리를 그립니다.Draws one or more edges of the specified bounding rectangle.

DrawImage(Graphics, Rectangle, Image) DrawImage(Graphics, Rectangle, Image) DrawImage(Graphics, Rectangle, Image) DrawImage(Graphics, Rectangle, Image)

지정된 범위 내에 지정된 이미지를 그립니다.Draws the specified image within the specified bounds.

DrawImage(Graphics, Rectangle, ImageList, Int32) DrawImage(Graphics, Rectangle, ImageList, Int32) DrawImage(Graphics, Rectangle, ImageList, Int32) DrawImage(Graphics, Rectangle, ImageList, Int32)

지정된 범위 내의 지정된 ImageList에서 이미지를 그립니다.Draws the image from the specified ImageList within the specified bounds.

DrawParentBackground(IDeviceContext, Rectangle, Control) DrawParentBackground(IDeviceContext, Rectangle, Control) DrawParentBackground(IDeviceContext, Rectangle, Control) DrawParentBackground(IDeviceContext, Rectangle, Control)

지정된 영역에 컨트롤 부모의 배경을 그립니다.Draws the background of a control's parent in the specified area.

DrawText(IDeviceContext, Rectangle, String) DrawText(IDeviceContext, Rectangle, String) DrawText(IDeviceContext, Rectangle, String) DrawText(IDeviceContext, Rectangle, String)

기본 서식을 사용하여 지정된 범위 내에 텍스트를 그립니다.Draws text in the specified bounds using default formatting.

DrawText(IDeviceContext, Rectangle, String, Boolean) DrawText(IDeviceContext, Rectangle, String, Boolean) DrawText(IDeviceContext, Rectangle, String, Boolean) DrawText(IDeviceContext, Rectangle, String, Boolean)

비활성화된 텍스트를 표시하는 옵션을 사용하여 지정된 범위 내에 텍스트를 그립니다.Draws text in the specified bounds with the option of displaying disabled text.

DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags) DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags) DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags) DrawText(IDeviceContext, Rectangle, String, Boolean, TextFormatFlags)

비활성화된 텍스트를 표시하는 옵션과 다른 텍스트 서식을 적용하는 옵션을 사용하여 지정된 경계 사각형 내에 텍스트를 그립니다.Draws text in the specified bounding rectangle with the option of displaying disabled text and applying other text formatting.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBackgroundContentRectangle(IDeviceContext, Rectangle) GetBackgroundContentRectangle(IDeviceContext, Rectangle) GetBackgroundContentRectangle(IDeviceContext, Rectangle) GetBackgroundContentRectangle(IDeviceContext, Rectangle)

현재 비주얼 스타일 요소 배경의 콘텐츠 영역을 반환합니다.Returns the content area for the background of the current visual style element.

GetBackgroundExtent(IDeviceContext, Rectangle) GetBackgroundExtent(IDeviceContext, Rectangle) GetBackgroundExtent(IDeviceContext, Rectangle) GetBackgroundExtent(IDeviceContext, Rectangle)

현재 비주얼 스타일 요소의 전체 배경 영역을 반환합니다.Returns the entire background area for the current visual style element.

GetBackgroundRegion(IDeviceContext, Rectangle) GetBackgroundRegion(IDeviceContext, Rectangle) GetBackgroundRegion(IDeviceContext, Rectangle) GetBackgroundRegion(IDeviceContext, Rectangle)

현재 비주얼 스타일 요소의 배경 영역을 반환합니다.Returns the region for the background of the current visual style element.

GetBoolean(BooleanProperty) GetBoolean(BooleanProperty) GetBoolean(BooleanProperty) GetBoolean(BooleanProperty)

현재 비주얼 스타일 요소에 대해 지정된 부울 속성 값을 반환합니다.Returns the value of the specified Boolean property for the current visual style element.

GetColor(ColorProperty) GetColor(ColorProperty) GetColor(ColorProperty) GetColor(ColorProperty)

현재 비주얼 스타일 요소에 대해 지정된 색 속성 값을 반환합니다.Returns the value of the specified color property for the current visual style element.

GetEnumValue(EnumProperty) GetEnumValue(EnumProperty) GetEnumValue(EnumProperty) GetEnumValue(EnumProperty)

현재 비주얼 스타일 요소에 대해 지정된 열거 형식 속성 값을 반환합니다.Returns the value of the specified enumerated type property for the current visual style element.

GetFilename(FilenameProperty) GetFilename(FilenameProperty) GetFilename(FilenameProperty) GetFilename(FilenameProperty)

현재 비주얼 스타일 요소에 대해 지정된 파일 이름 속성 값을 반환합니다.Returns the value of the specified file name property for the current visual style element.

GetFont(IDeviceContext, FontProperty) GetFont(IDeviceContext, FontProperty) GetFont(IDeviceContext, FontProperty) GetFont(IDeviceContext, FontProperty)

현재 비주얼 스타일 요소에 대해 지정된 글꼴 속성 값을 반환합니다.Returns the value of the specified font property for the current visual style element.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetInteger(IntegerProperty) GetInteger(IntegerProperty) GetInteger(IntegerProperty) GetInteger(IntegerProperty)

현재 비주얼 스타일 요소에 대해 지정된 정수 속성 값을 반환합니다.Returns the value of the specified integer property for the current visual style element.

GetMargins(IDeviceContext, MarginProperty) GetMargins(IDeviceContext, MarginProperty) GetMargins(IDeviceContext, MarginProperty) GetMargins(IDeviceContext, MarginProperty)

현재 비주얼 스타일 요소에 대해 지정된 여백 속성 값을 반환합니다.Returns the value of the specified margins property for the current visual style element.

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType) GetPartSize(IDeviceContext, Rectangle, ThemeSizeType) GetPartSize(IDeviceContext, Rectangle, ThemeSizeType) GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

지정된 그리기 범위를 사용하여 현재 비주얼 스타일 파트에 대해 지정된 크기 속성 값을 반환합니다.Returns the value of the specified size property of the current visual style part using the specified drawing bounds.

GetPartSize(IDeviceContext, ThemeSizeType) GetPartSize(IDeviceContext, ThemeSizeType) GetPartSize(IDeviceContext, ThemeSizeType) GetPartSize(IDeviceContext, ThemeSizeType)

현재 비주얼 스타일 파트에 대해 지정된 크기 속성 값을 반환합니다.Returns the value of the specified size property of the current visual style part.

GetPoint(PointProperty) GetPoint(PointProperty) GetPoint(PointProperty) GetPoint(PointProperty)

현재 비주얼 스타일 요소에 대해 지정된 점 속성 값을 반환합니다.Returns the value of the specified point property for the current visual style element.

GetString(StringProperty) GetString(StringProperty) GetString(StringProperty) GetString(StringProperty)

현재 비주얼 스타일 요소에 대해 지정된 문자열 속성 값을 반환합니다.Returns the value of the specified string property for the current visual style element.

GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags) GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags) GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags) GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags)

지정된 초기 경계 사각형 내에 현재 비주얼 스타일 요소의 글꼴을 사용하여 그릴 때 지정된 문자열의 크기와 위치를 반환합니다.Returns the size and location of the specified string when drawn with the font of the current visual style element within the specified initial bounding rectangle.

GetTextExtent(IDeviceContext, String, TextFormatFlags) GetTextExtent(IDeviceContext, String, TextFormatFlags) GetTextExtent(IDeviceContext, String, TextFormatFlags) GetTextExtent(IDeviceContext, String, TextFormatFlags)

현재 비주얼 스타일 요소의 글꼴을 사용하여 그릴 때 지정된 문자열의 크기와 위치를 반환합니다.Returns the size and location of the specified string when drawn with the font of the current visual style element.

GetTextMetrics(IDeviceContext) GetTextMetrics(IDeviceContext) GetTextMetrics(IDeviceContext) GetTextMetrics(IDeviceContext)

현재 비주얼 스타일 요소에서 지정한 글꼴에 대한 정보를 검색합니다.Retrieves information about the font specified by the current visual style element.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
HitTestBackground(Graphics, Rectangle, Region, Point, HitTestOptions) HitTestBackground(Graphics, Rectangle, Region, Point, HitTestOptions) HitTestBackground(Graphics, Rectangle, Region, Point, HitTestOptions) HitTestBackground(Graphics, Rectangle, Region, Point, HitTestOptions)

현재 비주얼 스타일 요소의 배경과 지정된 범위 내에 점이 포함되는지 여부를 나타내는 적중 테스트 코드를 반환합니다.Returns a hit test code indicating whether the point is contained in the background of the current visual style element and within the specified bounds.

HitTestBackground(IDeviceContext, Rectangle, IntPtr, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, IntPtr, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, IntPtr, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, IntPtr, Point, HitTestOptions)

현재 비주얼 스타일 요소의 배경과 지정된 영역 내에 점이 포함되는지 여부를 나타내는 적중 테스트 코드를 반환합니다.Returns a hit test code indicating whether the point is contained in the background of the current visual style element and within the specified region.

HitTestBackground(IDeviceContext, Rectangle, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, Point, HitTestOptions) HitTestBackground(IDeviceContext, Rectangle, Point, HitTestOptions)

현재 비주얼 스타일 요소의 배경에 점이 포함되는지 여부를 나타내는 적중 테스트 코드를 반환합니다.Returns a hit test code indicating whether a point is contained in the background of the current visual style element.

IsBackgroundPartiallyTransparent() IsBackgroundPartiallyTransparent() IsBackgroundPartiallyTransparent() IsBackgroundPartiallyTransparent()

현재 비주얼 스타일 요소의 배경에 반투명 또는 알파 블렌드 부분이 있는지 여부를 나타냅니다.Indicates whether the background of the current visual style element has any semitransparent or alpha-blended pieces.

IsElementDefined(VisualStyleElement) IsElementDefined(VisualStyleElement) IsElementDefined(VisualStyleElement) IsElementDefined(VisualStyleElement)

지정된 비주얼 스타일 요소가 현재 비주얼 스타일에 정의되어 있는지 여부를 확인합니다.Determines whether the specified visual style element is defined by the current visual style.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
SetParameters(String, Int32, Int32) SetParameters(String, Int32, Int32) SetParameters(String, Int32, Int32) SetParameters(String, Int32, Int32)

VisualStyleRenderer를 지정된 클래스, 파트 및 상태 값에서 나타내는 비주얼 스타일 요소로 설정합니다.Sets this VisualStyleRenderer to the visual style element represented by the specified class, part, and state values.

SetParameters(VisualStyleElement) SetParameters(VisualStyleElement) SetParameters(VisualStyleElement) SetParameters(VisualStyleElement)

VisualStyleRenderer를 지정된 VisualStyleElement에서 나타내는 비주얼 스타일 요소로 설정합니다.Sets this VisualStyleRenderer to the visual style element represented by the specified VisualStyleElement.

ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상

추가 정보