DrawToolTipEventArgs.Graphics プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DrawToolTipEventArgs.Graphics プロパティの意味・解説 

DrawToolTipEventArgs.Graphics プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ToolTip描画使用されるグラフィックス表面取得します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

ToolTipカスタム描画する方法次のコード例示します。この例では、ToolTip作成しForm 上にある 3 つの Button コントロール関連付けています。また、OwnerDraw プロパティtrue設定しDraw イベント処理してます。Draw イベント ハンドラでは、どのボタンToolTip表示されるかをDrawToolTipEventArgs.AssociatedControl プロパティ指定し、それによって ToolTipカスタム描画されます。

DrawText メソッドDrawBackground メソッド使用方法、および Graphics プロパティ使用方法次のコード例抜粋示しますコード例全体については、DrawToolTipEventArgs クラス概要参照してください

' 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)
// 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 == 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.get_AssociatedControl().Equals(button1)) {
    // Draw the standard background.
    e.DrawBackground();
    // Draw the custom border to appear 3-dimensional.
    e.get_Graphics().DrawLines(SystemPens.get_ControlLightLight(),
        new Point[] { new Point(0, e.get_Bounds().get_Height()
 - 1),
        new Point(0, 0), new Point(e.get_Bounds().get_Width()
 - 1, 0)});
    e.get_Graphics().DrawLines(SystemPens.get_ControlDarkDark(),
        new Point[] { new Point(0, e.get_Bounds().get_Height()
 - 1),
        new Point(e.get_Bounds().get_Width() - 1,
        e.get_Bounds().get_Height() - 1),
        new Point(e.get_Bounds().get_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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DrawToolTipEventArgs クラス
DrawToolTipEventArgs メンバ
System.Windows.Forms 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からDrawToolTipEventArgs.Graphics プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDrawToolTipEventArgs.Graphics プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDrawToolTipEventArgs.Graphics プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DrawToolTipEventArgs.Graphics プロパティ」の関連用語

DrawToolTipEventArgs.Graphics プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DrawToolTipEventArgs.Graphics プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS