TrackBarRenderer.GetTopPointingThumbSize(Graphics, TrackBarThumbState) 메서드

정의

위쪽을 가리키는 트랙 표시줄 슬라이더(엄지 단추)의 크기를 픽셀 단위로 반환합니다.

public:
 static System::Drawing::Size GetTopPointingThumbSize(System::Drawing::Graphics ^ g, System::Windows::Forms::VisualStyles::TrackBarThumbState state);
public static System.Drawing.Size GetTopPointingThumbSize (System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.TrackBarThumbState state);
static member GetTopPointingThumbSize : System.Drawing.Graphics * System.Windows.Forms.VisualStyles.TrackBarThumbState -> System.Drawing.Size
Public Shared Function GetTopPointingThumbSize (g As Graphics, state As TrackBarThumbState) As Size

매개 변수

g
Graphics

이 작업에서 사용할 Graphics입니다.

state
TrackBarThumbState

슬라이더의 표시 상태를 지정하는 TrackBarThumbState 값 중 하나입니다.

반환

Size

슬라이더의 크기를 픽셀 단위로 지정하는 Size입니다.

예외

운영 체제에서 비주얼 스타일을 지원하지 않는 경우

또는

운영 체제에서 사용자가 비주얼 스타일을 사용하지 않도록 설정한 경우

또는

비주얼 스타일이 애플리케이션 창의 클라이언트 영역에 적용되지 않은 경우

예제

다음 코드 예제에서는 합니다 GetTopPointingThumbSize 에서 사용 하는 사각형의 크기를 결정 하는 메서드는 DrawTopPointingThumb 슬라이더를 그릴 메서드. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 TrackBarRenderer 클래스입니다.

    // Calculate the sizes of the bar, thumb, and ticks rectangle.
private:
    void SetupTrackBar()
    {
        if (!TrackBarRenderer::IsSupported)
        {
            return;
        }

        Graphics^ g = this->CreateGraphics();

        // Calculate the size of the track bar.
        trackRectangle.X = ClientRectangle.X + 2;
        trackRectangle.Y = ClientRectangle.Y + 28;
        trackRectangle.Width = ClientRectangle.Width - 4;
        trackRectangle.Height = 4;

        // Calculate the size of the rectangle in which to
        // draw the ticks.
        ticksRectangle.X = trackRectangle.X + 4;
        ticksRectangle.Y = trackRectangle.Y - 8;
        ticksRectangle.Width = trackRectangle.Width - 8;
        ticksRectangle.Height = 4;

        tickSpace = ((float)ticksRectangle.Width - 1) /
            ((float)numberTicks - 1);

        // Calculate the size of the thumb.
        thumbRectangle.Size =
            TrackBarRenderer::GetTopPointingThumbSize(g,
            TrackBarThumbState::Normal);

        thumbRectangle.X = CurrentTickXCoordinate();
        thumbRectangle.Y = trackRectangle.Y - 8;
    }
// Calculate the sizes of the bar, thumb, and ticks rectangle.
private void SetupTrackBar()
{
    if (!TrackBarRenderer.IsSupported)
        return;

    using (Graphics g = this.CreateGraphics())
    {
        // Calculate the size of the track bar.
        trackRectangle.X = ClientRectangle.X + 2;
        trackRectangle.Y = ClientRectangle.Y + 28;
        trackRectangle.Width = ClientRectangle.Width - 4;
        trackRectangle.Height = 4;

        // Calculate the size of the rectangle in which to 
        // draw the ticks.
        ticksRectangle.X = trackRectangle.X + 4;
        ticksRectangle.Y = trackRectangle.Y - 8;
        ticksRectangle.Width = trackRectangle.Width - 8;
        ticksRectangle.Height = 4;

        tickSpace = ((float)ticksRectangle.Width - 1) /
            ((float)numberTicks - 1);

        // Calculate the size of the thumb.
        thumbRectangle.Size =
            TrackBarRenderer.GetTopPointingThumbSize(g,
            TrackBarThumbState.Normal);

        thumbRectangle.X = CurrentTickXCoordinate();
        thumbRectangle.Y = trackRectangle.Y - 8;
    }
}
' Calculate the sizes of the bar, thumb, and ticks rectangle.
Private Sub SetupTrackBar()
    If Not TrackBarRenderer.IsSupported Then
        Return
    End If
    Using g As Graphics = Me.CreateGraphics()
        ' Calculate the size of the track bar.
        trackRectangle.X = ClientRectangle.X + 2
        trackRectangle.Y = ClientRectangle.Y + 28
        trackRectangle.Width = ClientRectangle.Width - 4
        trackRectangle.Height = 4

        ' Calculate the size of the rectangle in which to 
        ' draw the ticks.
        ticksRectangle.X = trackRectangle.X + 4
        ticksRectangle.Y = trackRectangle.Y - 8
        ticksRectangle.Width = trackRectangle.Width - 8
        ticksRectangle.Height = 4

        tickSpace = (CSng(ticksRectangle.Width) - 1) / _
            (CSng(numberTicks) - 1)

        ' Calculate the size of the thumb.
        thumbRectangle.Size = _
            TrackBarRenderer.GetTopPointingThumbSize( _
            g, TrackBarThumbState.Normal)

        thumbRectangle.X = CurrentTickXCoordinate()
        thumbRectangle.Y = trackRectangle.Y - 8
    End Using
End Sub

설명

슬라이더의 크기는 운영 체제의 현재 비주얼 스타일에 의해 결정 됩니다.

이 메서드를 호출 하기 전에 확인 해야 하는 값을 IsSupported 속성은 true합니다.

적용 대상