如何使用FOR迴圈讓元件也跟著跳動 |
答題得分者是:ha0009
|
gwokae
一般會員 發表:1 回覆:2 積分:0 註冊:2004-03-03 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
TEXTANIM.ZIP
http://www.delphiarea.com/products/textanim/textanim.zip
TTextAnimator 是以 Sun Microsystems 公司知名的 Java Applet 範例程式 NervousText 為基礎,能夠讓文字以四種不同型式動態跳動的視覺化元件 ( 1.3 版,附原始程式碼 ),作者 : Kambiz R. Khojasteh。 網海無涯,學無止境! 發表人 - qoo1234 於 2004/04/17 14:55:07
|
gwokae
一般會員 發表:1 回覆:2 積分:0 註冊:2004-03-03 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Button1: TButton; Timer1: TTimer; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; L,T:integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin L:=Label1.left; T :=Label1.top; Timer1.Enabled := Not Timer1.Enabled; end; //控制Label向右移動 procedure TForm1.Timer1Timer(Sender: TObject); begin if Label1.Left>=100 then begin Label1.Top :=L; Label1.Left:=T; end else begin Label1.Top :=L; Label1.Left:=Label1.Left 5; end; end; end.網海無涯,學無止境! 發表人 - qoo1234 於 2004/04/17 15:36:50 |
gwokae
一般會員 發表:1 回覆:2 積分:0 註冊:2004-03-03 發送簡訊給我 |
|
ha0009
版主 發表:16 回覆:507 積分:639 註冊:2002-03-16 發送簡訊給我 |
你好:
給你一個程序研究研究,雖然實用性不高,但也是一種物件使用的技巧
< class="code">
uses
TypInfo; // 改變多個相同類型的物件相同屬性的值
procedure ChangeSameComponentProp (ParentComponent : TComponent; ComponentClass : TComponentClass; Const PropName : String; const Value: array of Variant);
var
idx, Cnt : integer;
begin
if GetPropInfo(ComponentClass, PropName) = nil then
raise Exception.CreateFmt('指定的 %s 類別並沒有指定的 %s 屬性', [ComponentClass.ClassName, PropName]);
Cnt := Low (Value);
for idx := 0 to ParentComponent.ComponentCount - 1 do begin
if ParentComponent.Components [idx] is ComponentClass then
SetPropValue (ParentComponent.Components [idx], PropName, Value [Cnt]);
Inc (Cnt);
if Cnt > High (Value) then break;
end;
end; procedure TForm1.Button1Click(Sender: TObject);
begin
// 呼叫範例
ChangeSameComponentProp (Self, TLabel, 'Caption', ['11111', '22222', '33333', '444444', '55555']);
end;
|
catseye
一般會員 發表:0 回覆:1 積分:0 註冊:2002-04-14 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |