DrawToolTipEventArgs.Graphics Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
çiziminde ToolTipkullanılan grafik yüzeyini alır.
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
Özellik Değeri
öğesinin Graphics çizildiği yer ToolTip.
Örnekler
Aşağıdaki kod örneğinde özel çizim işleminin nasıl yapılacağını gösterilmektedir ToolTip. Örnek bir ToolTip oluşturur ve üzerinde bulunan üç Button denetimle Formilişkilendirir. Örnek, özelliğini true olarak ayarlar OwnerDraw ve olayı işler Draw . Olay işleyicisinde Draw , ToolTip özelliği tarafından gösterildiği gibi öğesinin ToolTip hangi düğme için görüntülendiğine bağlı olarak özel olarak çizilir DrawToolTipEventArgs.AssociatedControl .
Aşağıdaki kod alıntısı, ve DrawBackground yöntemlerinin DrawText ve özelliğinin Graphics kullanılmasını gösterir. Kod örneğinin DrawToolTipEventArgs tamamı için sınıfa genel bakış bölümüne bakın.
// 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)
Açıklamalar
nesnesini kullanarak Graphics bir ToolTipöğesinin belirli görsel yönlerinin çizimini özelleştirebilirsiniz. Örneğin, yöntemini kullanarak Graphics.FillRectangle kendi ToolTip arka planınızı çizebilirsiniz.
özelliği tarafından Bounds belirtilen dikdörtgenin dışında yapılan herhangi bir özel çizim gösterilmez. Olayı işleyerek gösterilmeden önce öğesinin ToolTip.Popup sınırlarını ToolTip artırabilirsiniz.
DrawToolTipEventArgs sınıfı, işletim sistemi tarafından kullanılan standart şekilde tek tek bölümlerini ToolTip çizmek için ve DrawTextDrawBorder yöntemlerini de sağlarDrawBackground. Diğer bölümleri özelleştirirken ToolTip'inizin bazı bölümlerini standart hale getirmek için nesne yöntemleriyle Graphics birlikte bu yöntemleri kullanabilirsiniz.