DrawToolTipEventArgs.Graphics 속성

정의

ToolTip을 그리는 데 사용되는 그래픽 표면을 가져옵니다.

public:
 property System::Drawing::Graphics ^ Graphics { System::Drawing::Graphics ^ get(); };
public System.Drawing.Graphics Graphics { get; }
member this.Graphics : System.Drawing.Graphics
Public ReadOnly Property Graphics As Graphics

속성 값

Graphics을 그릴 ToolTip입니다.

예제

다음 코드 예제에서는 사용자 지정 그리기 방법은 ToolTip합니다. 이 예에서는 만듭니다는 ToolTip 3 연결 Button 컨트롤에 있는 Form. 예제에서는 합니다 OwnerDraw 속성을 true로 처리 합니다 Draw 이벤트입니다. 에 Draw 이벤트 처리기는 ToolTip 는 사용자 지정 단추에 따라 다르게 그려집니다를 ToolTip 나타난 것 처럼 표시 되는 DrawToolTipEventArgs.AssociatedControl 속성.

다음 코드 부분은 사용을 보여 줍니다.는 DrawText 하 고 DrawBackground 메서드 및 사용 하 여를 Graphics 속성. 참조 된 DrawToolTipEventArgs 전체 코드 예제에 대 한 클래스 개요입니다.

// Draw a custom 3D border if the ToolTip is for button1.
if ( e->AssociatedControl == button1 )
{
   // Draw the standard background.
   e->DrawBackground();
   
   // Draw the custom border to appear 3-dimensional.
   array<Point>^ temp1 = {Point(0,e->Bounds.Height - 1),Point(0,0),Point(e->Bounds.Width - 1,0)};
   e->Graphics->DrawLines( SystemPens::ControlLightLight, temp1 );
   array<Point>^ temp2 = {Point(0,e->Bounds.Height - 1),Point(e->Bounds.Width - 1,e->Bounds.Height - 1),Point(e->Bounds.Width - 1,0)};
   e->Graphics->DrawLines( SystemPens::ControlDarkDark, temp2 );
   
   // Specify custom text formatting flags.
   TextFormatFlags sf = static_cast<TextFormatFlags>(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter | TextFormatFlags::NoFullWidthCharacterBreak);
   
   // Draw the standard text with customized formatting options.
   e->DrawText( sf );
}
// Draw a custom 3D border if the ToolTip is for button1.
if (e.AssociatedControl == button1)
{
    // Draw the standard background.
    e.DrawBackground();

    // Draw the custom border to appear 3-dimensional.
    e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] {
        new Point (0, e.Bounds.Height - 1), 
        new Point (0, 0), 
        new Point (e.Bounds.Width - 1, 0)
    });
    e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] {
        new Point (0, e.Bounds.Height - 1), 
        new Point (e.Bounds.Width - 1, e.Bounds.Height - 1), 
        new Point (e.Bounds.Width - 1, 0)
    });

    // Specify custom text formatting flags.
    TextFormatFlags sf = TextFormatFlags.VerticalCenter |
                         TextFormatFlags.HorizontalCenter |
                         TextFormatFlags.NoFullWidthCharacterBreak;

    // Draw the standard text with customized formatting options.
    e.DrawText(sf);
}
' Draw a custom 3D border if the ToolTip is for button1.
If (e.AssociatedControl Is button1) Then
    ' Draw the standard background.
    e.DrawBackground()

    ' Draw the custom border to appear 3-dimensional.
    e.Graphics.DrawLines( _
        SystemPens.ControlLightLight, New Point() { _
        New Point(0, e.Bounds.Height - 1), _
        New Point(0, 0), _
        New Point(e.Bounds.Width - 1, 0)})
    e.Graphics.DrawLines( _
        SystemPens.ControlDarkDark, New Point() { _
        New Point(0, e.Bounds.Height - 1), _
        New Point(e.Bounds.Width - 1, e.Bounds.Height - 1), _
        New Point(e.Bounds.Width - 1, 0)})

    ' Specify custom text formatting flags.
    Dim sf As TextFormatFlags = TextFormatFlags.VerticalCenter Or _
                         TextFormatFlags.HorizontalCenter Or _
                         TextFormatFlags.NoFullWidthCharacterBreak

    ' Draw standard text with customized formatting options.
    e.DrawText(sf)

설명

사용할 합니다 Graphics 개체의 시각적 측면 특정 그리기를 사용자 지정 하는 ToolTip합니다. 예를 들어, 사용자 고유의 도구 설명 배경을 사용 하 여 그릴 수 있습니다는 Graphics.FillRectangle 메서드.

모든 사용자 지정 그리기는 지정 된 영역 외부에서 수행 되는 Bounds 속성 표시 되지 것입니다. 범위를 확장할 수는 ToolTip 처리 하 여 표시 되기 전에 ToolTip.Popup 이벤트입니다.

DrawToolTipEventArgs 클래스도 제공 합니다 DrawBackground, DrawTextDrawBorder 의 개별 부분을 그리는 방법을 ToolTip 운영 체제에서 사용 되는 표준 방식입니다. 이러한 메서드를 사용 하 여 함께 합니다 Graphics 개체 메서드와 다른 부분을 사용자 지정 하는 동안 표준, 도구 설명의 일부를 확인 합니다.

적용 대상