DrawToolTipEventArgs.Graphics Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri a rajzhoz ToolTiphasznált grafikus felületet.
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
Tulajdonság értéke
Példák
Az alábbi példakód bemutatja, hogyan rajzolhatja meg egyénileg a ToolTip. A példa létrehoz egy ToolTip , és három Button vezérlőhöz társítja azt a Form. A példa igaz értékre állítja a OwnerDraw tulajdonságot, és kezeli az eseményt Draw . Az eseménykezelőben az DrawToolTip egyéni rajzolás a tulajdonság által ToolTip jelzett gombtól DrawToolTipEventArgs.AssociatedControl függően eltérően történik.
Az alábbi kódrészlet bemutatja a metódusok és DrawText a DrawBackgroundGraphics tulajdonság használatát. A teljes kód példáját az DrawToolTipEventArgs osztály áttekintésében tekintheti meg.
// 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)
Megjegyzések
Az objektummal Graphics testre szabhatja egy adott vizualizáció egyes aspektusainak rajzát ToolTip. A metódussal Graphics.FillRectangle például saját elemleírás-hátteret is rajzolhat.
A tulajdonság által Bounds megadott téglalapon kívül végzett egyéni rajzok nem jelennek meg. Az esemény kezelésével ToolTip növelheti a ToolTip.Popup megjelenített előtti korlátokat.
Az DrawToolTipEventArgs osztály emellett az DrawBackgroundDrawTextDrawBorder operációs rendszer által használt szokásos módon biztosítja az ToolTip egyes részeinek rajzolását és metódusait. Ezekkel a metódusokkal az Graphics objektummetódusokkal együtt szabványossá teheti az elemleírás egyes részeit, miközben más részeket is testre szabhat.