好吧,我的是在lblText_paint 方法中重绘的,用
e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上
e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上
解决方案 »
- 求助高手:Winform 里的Hscrollbar 控件
- App.Config配置问题!散分...
- 我把ASP.NET的代码都写好后,点生成网站后要怎么办
- 怎样可以模拟鼠标在窗口的头部按下后可以移动窗口(WINFORM)???
- 有挑战性的问题
- 通过handler下载的文件本地没有问题但部署到服务器上就不能下载也没有错误提示
- 如何突破互联网IP封锁?哪里可以下载到“三角男孩”软件?
- c++/c写的dll定义的char far *类型在c#中如何定义
- 急!高分求救!邮件的编码问题??
- 请问个位高手一个关于图片处理的问题
- C#日文XP下,连接access导入数据报错,具体如下图,求解决
- iframe高度自适应问题
{
Rectangle rectFont = new Rectangle();
SolidBrush SbFont = null;
e.Graphics.PageUnit = GraphicsUnit.Pixel;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
SbFont = new SolidBrush(ColorTranslator.FromWin32(showText.FontColor));
Point pt = new Point(0, 0);
switch (showText.Direction)
{//滚动方向0:向右滚动,1:向左滚动,2:向下滚动,3:向上滚动。
case 0:
if (x >= this.Width)
x = -((int)oneSize.Width + 1);
else
x += showText.Speed;
pt.X = x;
break;
case 1:
if (x <= -((int)oneSize.Width + 1))
x = this.Width;
else
x -= showText.Speed;
pt.X = x;
break;
case 2:
if (y >= this.Height)
y = -((int)oneSize.Height + 1);
else
y += showText.Speed;
pt.Y = y;
break;
case 3:
if (y <= -((int)oneSize.Height + 1))
y = this.Height;
else
y -= showText.Speed;
pt.Y = y;
break; default: break;
}
e.Graphics.TranslateTransform(pt.X, pt.Y);
if (showText.TextDirection == 1)
{
rectFont = new Rectangle(0, 0, (int)oneSize.Width + 1, (int)oneSize.Height);
}
else
{
rectFont = new Rectangle(0, lblText.Height / 9, (int)oneSize.Width + 1, (int)oneSize.Height);
}
e.Graphics.DrawString(showText.Caption, getFont(), SbFont,rectFont,GetFormat());//将对应的文字写到矩形上
e.Graphics.Flush();
}
重绘的代码,现在就是有卡顿的感觉,滚动的不流畅,我用timer进行刷新。
//Init
th = new Thread(new ThreadStart(XXXX));
th.Start();//XXXX
void XXXX()
{
while (!lblText.Created);
while (true)
{
if (!lblText.Created) break;
lblText.Invalidate();
Thread.Sleep(10);
}
}//Paint上面代码SbFont后面要释放
SbFont.Dispose();