3

次の内容のカスタム ツールチップを作成したい:

  • 右上隅の画像
  • 左側のテキスト

現在、ToolTip Objekt から継承するクラスがあります。

class CustomToolTip : ToolTip
{
    public CustomToolTip()
    {
        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, 100);
    }

    private void OnDraw(object sender, DrawToolTipEventArgs e)
    {

    }
}

しかし、テキスト付きの画像を表示するために「OnDraw-Event」で何をすべきかわかりません。

ご協力ありがとうございました

4

2 に答える 2

1

GDI+をお試しください

protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    Image img = Image.FromFile("C:\filepath\filename.jpg");
    e.Graphics.DrawImage(img, 0, 0);
    var YourTipTextPoint = new Point(0,0);
    e.Graphics.DrawString("Hello World", SystemFonts.DefaultFont, Brushes.Black, YourTipTextPoint); 
}
于 2013-04-19T08:11:08.840 に答える