自行產生物件問題 |
尚未結案
|
GiGi
一般會員 發表:17 回覆:21 積分:7 註冊:2002-10-19 發送簡訊給我 |
|
ccchen
版主 發表:61 回覆:940 積分:1394 註冊:2002-04-15 發送簡訊給我 |
type //以下是型態定義, 不是變數宣告 TForm2 = class(TForm) //此處為published區, 以Form來說, designTime加入之元件均放在此處 //自行宣告之物件不可放於此 private //可放在此處 { Private declarations } public //可放在此處 { Public declarations } end; var //如果是Global之宣告, 不屬於任何class可於此宣告 Labels : Tobject Label1 :TLabel; Label2 :TLabel; |
Leway
一般會員 發表:43 回覆:71 積分:22 註冊:2003-07-29 發送簡訊給我 |
|
GiGi
一般會員 發表:17 回覆:21 積分:7 註冊:2002-10-19 發送簡訊給我 |
謝謝回應
cchen 與 Leway 所列出來的code 我都有試了 在編譯的時候 就是單純的放入各位所列出的還是不能過 煩請各位先進再予以幫忙 var
Labels : Tobject
Label1 :TLabel;
Label2 :TLabel 錯誤訊息
[Error] Unit1.pas(28): Invalid compiler directive: 'Label1' type
Labels = Tobject
Label1 = TLabel;
Label2 = TLabel;
end; 錯誤訊息
[Error] Unit1.pas(10): ';' expected but identifier 'Label1' found
[Error] Unit1.pas(12): 'IMPLEMENTATION' expected but ';' found
[Error] Unit1.pas(26): '.' expected but 'IMPLEMENTATION' found var
Labels : object
Label1 :TLabel;
Label2 :TLabel;
錯誤訊息 [Error] Unit1.pas(27): Class, interface and object types only allowed in type section
[Error] Unit1.pas(28): Local class, interface or object types not allowed
[Error] Unit1.pas(31): 'END' expected but 'BEGIN' found
|
GiGi
一般會員 發表:17 回覆:21 積分:7 註冊:2002-10-19 發送簡訊給我 |
試出來了 unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TLabels = class
Label1 : TLabel;
Label2 : TLabel;
end; 但是 又有問題需要幫忙
我怎麼指定Label 的event??
我試的是這樣(Click 是 procedure Click(Sender:TObject);)
procedure TForm1.FormCreate(Sender: TObject);
var cl:TLabels;
begin
cl.Label1.OnClick:=Click(nil);
end; 錯誤訊息 [Error] Unit1.pas(37): Incompatible types: 'TNotifyEvent' and 'procedure, untyped pointer or untyped parameter'
|
GiGi
一般會員 發表:17 回覆:21 積分:7 註冊:2002-10-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |