如何使用 DrawThemeTextEx 在 StatusStrip 上绘制发光文本?
我正在尝试使用我找到的 DrawThemeTextEx 类在 .NET StatusStrip 中绘制航空风格的发光文本。这是我当前的代码,我将其用作 StatusStrip 的渲染器:
Class GlassStatusRenderer
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
但是,问题是发光文本似乎是在 StatusStrip 下方绘制的。关于如何让它在 StatusStrip 上绘制有什么想法吗?
编辑:是否可以以某种方式将其包装在继承 ToolStripStatusLabel 的类中?我尝试过,但没有走得太远。
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 GlassStatusRenderer
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我不知道 StatusStrip,但您可以使用继承 System.Windows.Forms.StatusBar 或 System.Windows.Forms.Control 的类并重写 OnPaint 事件来绘制发光文本。这是一个示例:
public class ctlStatusBar : Control
{
protected override void OnHandleCreated(EventArgs e)
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);
基.OnHandleCreated(e);
}
}
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);
}
}