[Delphi 七]自己写了两个控件,测试的时候,程序退出会偶尔弹出CPU窗口
[Delphi 7]自己写了两个控件,测试的时候,程序退出会偶尔弹出CPU窗口
自己写了两个控件 TViewLabel 和 TControlsScroller ,TViewLabel 可以单独使用也可配合TControlsScroller 使用,当配合TControlsScroller 使用时,就可以滚动了,滚动由TControlsScroller 负责,目前这两个控件功能挺强的,也算是放这里开源了。
测试的时候,程序退出会偶尔弹出CPU窗口,但不是错误信息,已经查到出错的语句在哪里,但是就是不知道怎么解决。下面贴代码:
自己写了两个控件 TViewLabel 和 TControlsScroller ,TViewLabel 可以单独使用也可配合TControlsScroller 使用,当配合TControlsScroller 使用时,就可以滚动了,滚动由TControlsScroller 负责,目前这两个控件功能挺强的,也算是放这里开源了。
测试的时候,程序退出会偶尔弹出CPU窗口,但不是错误信息,已经查到出错的语句在哪里,但是就是不知道怎么解决。下面贴代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ViewLabel, ControlsScroller, ExtCtrls, StdCtrls, TntExtCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
procedure FormCreate(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
vlbl1 : TViewLabel;
vlbl2 : TViewLabel;
vlbl3 : TViewLabel;
i : Integer;
scrollder : TControlsscroller;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
str : string;
begin
str := '既包含了对用户界面的重要改善也包含了对80286和80386对内存管理技术的改进。为命令行式操, 0, 167, 255;'#$D#$A#$D#$A'Windows 3.0的汗马功劳。Windows 3.0具备了模, 167, 28, 255;';
vlbl1 := TViewLabel.Create(Self);
vlbl1.Left := 20;
vlbl1.Top := 100;
vlbl1.Width := 400;
vlbl1.Height := 100;
vlbl1.SubLabel.Font.Size := 40;
vlbl1.SubLabel.Font.Name := '黑体';
vlbl1.SubLabel.Font.Color := RGB(0, 255, 10);
vlbl1.Caption := 'Windows 1.0 可以显示256种颜色,窗口可以任意缩放';
vlbl1.Color := RGB(255, 255, 255);
vlbl1.Parent := Self;
vlbl1.ColorRule := str;
scrollder := TControlsscroller.Create(Self);
scrollder.Speed := 1;
scrollder.ResidenceTime := 1;
scrollder.Orientation := Vertica;
vlbl1.ControlsScroller := scrollder;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
//vlbl1.Scroll := NOT vlbl1.Scroll;
i := i + 1;
case i mod 3 of
0 :
vlbl1.Caption := 'Windows 1.0 可以显示256种颜色,窗口可以任意缩放';
1 :
vlbl1.Caption := '既包含了对用户界面的重要改善也包含了对80286和80386对内存管理技术的改进。为命令行式操';
2 :
vlbl1.Caption := #$D#$A'Windows 3.0的汗马功劳。Windows 3.0具备了模';
end;
end;
end.
unit ViewLabel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, ControlsScroller, StdCtrls,
Forms, Messages, Graphics, Windows;
type
TViewLabel = class(TCustomControl)
private
m_SubLabel : TLabel;
m_ControlsScroller : TControlsScroller;
m_OnResize : TNotifyEvent;
m_Color : TColor;
m_DefaultFontColor : TColor;
m_ColorTag : Integer;
m_ColorRule : String;
m_Scroll : Boolean;
m_DefaultLeft : Integer;
m_DefaultTop : Integer;
protected
procedure SetControlsScroller(value:TControlsScroller);
procedure SetScroll(value:Boolean);
procedure SetCaption(value:TCaption);