より多くの機能で強化したい単純な Tooltip クラスを作成しましたが、基本的な Tooltip だけでは、2 回目以降に表示されるときに境界線に沿って醜い縁取りが発生するという問題に遭遇しています。初めて表示されるときは、正しく表示されます。
なぜこれが起こっているのか誰にも教えてもらえますか?
using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
class CToolTip : ToolTip
{
public CToolTip()
{
this.OwnerDraw = true;
this.Popup += new PopupEventHandler(this.OnPopup);
this.Draw += new DrawToolTipEventHandler(this.OnDraw);
}
private void OnPopup(object sender, PopupEventArgs e)
{
e.ToolTipSize = new Size(200, 200);
}
private void OnDraw(object sender, DrawToolTipEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.FillRectangle(Brushes.LightYellow, new Rectangle(0, 0, 200, 200));
}
}
CToolTip とボタンをフォームに追加しました。ホバー イベントのイベント ハンドラーを追加し、ボタン ホバーに表示します。
this.button1.MouseHover += new System.EventHandler(this.button1_MouseHover);
private void button1_MouseHover(object sender, EventArgs e)
{
cTip.SetToolTip(button1, "This is a test");
}