1

WinForm アプリケーションでカスタム ツールチップ クラスを使用しています。それはうまくいきます。しかし、バルーンとして表示したいと思います。これが私のコードです-

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) // use this event to set the size of the tool tip
    {
        e.ToolTipSize = new Size(200, 100);
    }

    private void OnDraw(object sender, DrawToolTipEventArgs e) // use this event to customise the tool tip
    {
        Graphics g = e.Graphics;

        LinearGradientBrush b = new LinearGradientBrush(e.Bounds,
            Color.GreenYellow, Color.MintCream, 45f);

        g.FillRectangle(b, e.Bounds);

        g.DrawRectangle(new Pen(Brushes.Red, 1), new Rectangle(e.Bounds.X, e.Bounds.Y,
            e.Bounds.Width - 1, e.Bounds.Height - 1));

        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Silver,
            new PointF(e.Bounds.X + 6, e.Bounds.Y + 6)); // shadow layer
        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Black,
            new PointF(e.Bounds.X + 5, e.Bounds.Y + 5)); // top layer

        b.Dispose();
    }
}

なにか提案を?

期待して感謝します。

4

1 に答える 1

1

楕円を描いてから、ピースを追加してターゲットを指すことができます。

しかし、デフォルトのツールチップ コントロールを使用しない理由はありません。

true に設定すると次のようになるIsBalloonフラグがあります。

ここに画像の説明を入力

于 2013-04-04T08:52:33.487 に答える