开发者

How to draw glowing text on StatusStrip with DrawThemeTextEx?

I'm trying to draw aero-styled glowing text in a .NET StatusStrip with a DrawThemeTextEx class I found. This is my current code which I use as a renderer for the StatusStrip:

Class GlassS开发者_如何转开发tatusRenderer
Inherits System.Windows.Forms.ToolStripProfessionalRenderer

Protected Overrides Sub OnRenderToolStripBackground(ByVal e As System.Windows.Forms.ToolStripRenderEventArgs)
    e.Graphics.Clear(Color.Transparent)
End Sub

Protected Overrides Sub OnRenderItemText(ByVal e As System.Windows.Forms.ToolStripItemTextRenderEventArgs)
    e.Graphics.Clear(Color.Transparent)

    Dim glowingText As New GlassText
    glowingText.DrawTextOnGlass(Form1.Handle, e.Text, e.TextFont, New Rectangle(e.TextRectangle.Left, e.ToolStrip.Top - 10, e.TextRectangle.Width, e.TextRectangle.Height), 6)
End Sub

End Class

The problem however, is that the glowing text seems to be drawn below the StatusStrip. Any idea on how to get it to draw on the StatusStrip?

EDIT: Is it possible to somehow wrap this in a class which inherits ToolStripStatusLabel? I tried but didn't get too far.


Well I don't know about a StatusStrip but you can use a class that inherits System.Windows.Forms.StatusBar or System.Windows.Forms.Control and override the OnPaint event to draw glowing text. here's an example:

public class ctlStatusBar : Control { protected override void OnHandleCreated(EventArgs e) { SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); base.OnHandleCreated(e); }

    protected override void OnPaint(PaintEventArgs e)
    {
        DrawStatusBar(e.Graphics);
    }

    private void DrawStatusBar(Graphics g)
    {
        if (Width < 1 || Height < 1) return;

        IntPtr primaryHdc = g.GetHdc();
        IntPtr memoryHdc = Global.CreateCompatibleDC(primaryHdc);

        DrawGlowingText(primaryHdc, memoryHdc, new Rectangle(0, 0, Width, Height), RebarRenderer, p_Text);
    }

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜