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

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

DrawToolTipEventArgs.Bounds プロパティ

メモ : このプロパティは、.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カスタム描画されます。

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

ElseIf (e.AssociatedControl Is button2) Then
    ' Draw a custom background and text if the ToolTip is for button2.

    ' Draw the custom background.
    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds)

    ' Draw the standard border.
    e.DrawBorder()

    ' Draw the custom text.
    Dim sf As StringFormat = New
 StringFormat
    Try
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center
        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None
        sf.FormatFlags = StringFormatFlags.NoWrap

        Dim f As Font = New
 Font("Tahoma", 9)
        Try
            e.Graphics.DrawString(e.ToolTipText, f, _
                SystemBrushes.ActiveCaptionText, _
                RectangleF.op_Implicit(e.Bounds), sf)
        Finally
            f.Dispose()
        End Try
    Finally
        sf.Dispose()
    End Try
// Draw a custom background and text if the ToolTip is for button2.
else if (e.AssociatedControl == button2)
{
    // Draw the custom background.
    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds);

    // Draw the standard border.
    e.DrawBorder();

    // Draw the custom text.
    // The using block will dispose the StringFormat automatically.
    using (StringFormat sf = new StringFormat())
    {
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;
        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
        sf.FormatFlags = StringFormatFlags.NoWrap;
        using (Font f = new Font("Tahoma",
 9))
        {
            e.Graphics.DrawString(e.ToolTipText, f, 
                SystemBrushes.ActiveCaptionText, e.Bounds, sf);
        }
    }
}
// Draw a custom background and text if the ToolTip is for button2.
else

// Draw a custom background and text if the ToolTip is for button2.
if ( e->AssociatedControl == button2 )
{
   // Draw the custom background.
   e->Graphics->FillRectangle( SystemBrushes::ActiveCaption, e->Bounds );
   
   // Draw the standard border.
   e->DrawBorder();
   
   // Draw the custom text.
   // The using block will dispose the StringFormat automatically.
   StringFormat^ sf = gcnew StringFormat;
   try
   {
      sf->Alignment = StringAlignment::Center;
      sf->LineAlignment = StringAlignment::Center;
      sf->HotkeyPrefix = System::Drawing::Text::HotkeyPrefix::None;
      sf->FormatFlags = StringFormatFlags::NoWrap;
      System::Drawing::Font^ f = gcnew System::Drawing::Font( "Tahoma",9
 );
      try
      {
         e->Graphics->DrawString( e->ToolTipText, f, SystemBrushes::ActiveCaptionText,
 e->Bounds, sf );
      }
      finally
      {
         if ( f )
            delete safe_cast<IDisposable^>(f);
      }

   }
   finally
   {
      if ( sf )
         delete safe_cast<IDisposable^>(sf);
   }
}
// Draw a custom background and text if the ToolTip is for button2.
else {
    if (e.get_AssociatedControl().Equals(button2)) {
        // Draw the custom background.
        e.get_Graphics().FillRectangle(SystemBrushes.get_ActiveCaption(),
            e.get_Bounds());
        // Draw the standard border.
        e.DrawBorder();
        
        // Draw the custom text.
        // The using block will dispose the StringFormat automatically.
        StringFormat sf = new StringFormat();
        try {
            sf.set_Alignment(StringAlignment.Center);
            sf.set_LineAlignment(StringAlignment.Center);
            sf.set_HotkeyPrefix(System.Drawing.Text.HotkeyPrefix.None);
            sf.set_FormatFlags(StringFormatFlags.NoWrap);                    
            Font f = new Font("Tahoma", 9);
            try {
                e.get_Graphics().DrawString(e.get_ToolTipText(), f,
                    SystemBrushes.get_ActiveCaptionText(),
                    RectangleF.op_Implicit(e.get_Bounds()), sf);
            }
            finally {
                f.Dispose();
            }                    
        }
        finally {
            sf.Dispose();
        }                
    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DrawToolTipEventArgs クラス
DrawToolTipEventArgs メンバ
System.Windows.Forms 名前空間



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS