关于网友提出的“ Label移动闪烁的问题”问题疑问,本网通过在网上对“ Label移动闪烁的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: Label移动闪烁的问题
描述: 我用Label写了一个在时间段里向上移动的一系列字,请问高手我怎样实现在500毫秒里字体向上移动不闪烁???用什么函数能够达到字体的移动柔和性???
解决方案1: 再说一次:
用TLabel来实现不妥,代码我已给出;
如果你非要用TLabel来实现,试试
Label1.Parent.DoubleBuffered := True;
Label1.Transparent := True;
解决方案2: // 消除图片移动时的闪烁感
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
CheckBox1: TCheckBox;
procedure Timer1Timer(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Image1.Left>form1.Width then
Image1.Left:=-Image1.Width
else
Image1.Left:= Image1.Left+1;
end;
// 消除图片移动时的闪烁感
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
Form1.DoubleBuffered:=true
else
Form1.DoubleBuffered:=false;
end;
end.
解决方案3: procedure TFrmMain.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
if Panel.Text = '' then exit;
if Panel.Index = 3 then begin
with StatusBar1.Canvas do begin
if Panel.Text = '通讯正常' then
begin
Brush.Color := clGreen;
Ellipse(Rect.Left + 1, Rect.Top + 1, Rect.Left - Rect.Top + Rect.Bottom - 1, Rect.Bottom - 1);
Brush.Color := clBtnFace;
Font.Color := clGreen;
TextOut(Rect.Left + 22, Rect.Top + 1, Panel.Text);
end
else
begin
Brush.Color := clRed;
Ellipse(Rect.Left + 1, Rect.Top + 1, Rect.Left - Rect.Top + Rect.Bottom - 1, Rect.Bottom - 1);
Brush.Color := clBtnFace;
Font.Color := clRed;
TextOut(Rect.Left + 22, Rect.Top + 1, Panel.Text);
end;
end;
end;
//左移字符串
if Panel.Index = 4 then begin
with StatusBar1.Canvas do begin
TextOut(SBPos, Rect.Top + 1, Panel.Text);
Dec(SBPos);
if SBPos + TextWidth(Panel.Text) <= Rect.Left then
SBPos := Rect.Right;
end;
end;
end;
procedure TFrmMain.Timer2Timer(Sender: TObject);
begin
with StatusBar1 do begin
Panels[1].Text := FormatDateTime('yyyy年mm月dd日 dddd', Date);
Panels[2].Text := FormatDateTime('hh:nn', Time);
Repaint;
end;
end;
~~~~~~~~~~~~~~~
我以前写的一个,自己改改
SBPos: Integer;单元或窗体类全局变量,保存移动位置
以上介绍了“ Label移动闪烁的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2533676.html