首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

两个关于label的有关问题

2012-03-24 
两个关于label的问题1.如何实现label上文字的平滑滚动,即如何避免在滚动过程中文字的闪烁?我使用的是C++bu

两个关于label的问题
1.如何实现label上文字的平滑滚动,即如何避免在滚动过程中文字的闪烁?我使用的是C++builder5.0的版本.  
2.如何实现在label上的文字的闪烁效果?  
这2个问题看起来好象很对立的样子,实际是两个问题,第一个想屏蔽掉滚动时引起的闪烁;第二个问题是在文字未发生滚动时候,如何实现闪烁的效果?并且闪烁的间隔如何控制?  

哪个大哥能解决的,把解决的方法发到我的邮箱可以么?谢谢了  
我的邮箱是zhanglizhao2002@yahoo.com.cn  


[解决办法]
目前 TIMER的interval 设置为 5;
//---------------------------------------

#include <vcl.h>
#include <FileCtrl.hpp>
#include <IniFiles.hpp>
#pragma hdrstop

#include "Main.h "

//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm "
TForm1 *Form1;

Graphics::TBitmap *memCaption;
int iCaptionX = 0;
String strCaption;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
//设置窗口大小
Height = 57;
Left = 0;
Top = Screen-> Height-Height;
Width = Screen-> Width;

PaintBox1-> Align = alClient;

memCaption = new Graphics::TBitmap();
memCaption-> Canvas-> Handle = CreateCompatibleDC(Form1-> PaintBox1-> Canvas-> Handle);
memCaption-> Canvas-> Brush-> Color = clBlack;
memCaption-> Canvas-> FillRect(Rect(0,0,memCaption-> Width, memCaption-> Height));
memCaption-> Canvas-> Font-> Name = "幼圆 ";
memCaption-> Canvas-> Font-> Size = 42;
memCaption-> Canvas-> Font-> Color = clWhite;
memCaption-> Canvas-> Font-> Style = memCaption-> Canvas-> Font-> Style < <fsBold;
memCaption-> Height = Form1-> PaintBox1-> Height;
}
//---------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete memCaption;
Form1-> Timer1-> Enabled = false;
}
//---------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if (iCaptionX+memCaption-> Canvas-> TextWidth(strCaption) <= 0) //一组字幕播放完成,检查字幕是否发生变化
{
iCaptionX = Panel1-> Width;
strCaption = "欢迎光临 "; //此处可更换字幕
memCaption-> Width = memCaption-> Canvas-> TextWidth(strCaption);
memCaption-> Canvas-> TextOutA(0, 0, strCaption);
}
PaintBox1-> Canvas-> Draw(--iCaptionX, 0,memCaption); /**/
}
//---------------------------------------


//---------------------------------------

#ifndef MainH
#define MainH
#include <Classes.hpp>
#include <Controls.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------

class TForm1 : public TForm
{
__published:// IDE-managed Components
TTimer *Timer1;
TPanel *Panel1;
TPaintBox *PaintBox1;
void __fastcall FormCreate(TObject *Sender);
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);


private:// User declarations
public:// User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------
#endif

热点排行