自訂物件與RTTI的問題...! |
答題得分者是:ha0009
|
sanhang
一般會員 發表:12 回覆:25 積分:17 註冊:2002-08-31 發送簡訊給我 |
unit StudentObj; interface uses Messages,SysUtils,Classes,StdCtrls,dbtables,Dialogs,contnrs; type TStudent = Class(TObject) private fSTID : string; fSTName : string; fSTBirthday : TDateTime; fSTAge : integer; procedure SetID(Value : string); procedure SetName(Value : string); procedure SetBirthday(Value : TDateTime); procedure SetAge(Value : integer); public constructor Create; destructor Destroy;override; published property STID : string read fSTID write SetID; property STName : string read fSTName write SetName; property STBirthday : TDateTime read fSTBirthday write SetBirthday; property STAge : integer read fSTAge write SetAge; end; implementation { TStudent } constructor TStudent.Create; begin inherited Create; end; destructor TStudent.Destroy; begin inherited Destroy; end; procedure TStudent.SetAge(Value: integer); begin fSTAge := Value; end; procedure TStudent.SetBirthday(Value: TDateTime); begin fSTBirthday := Value; end; procedure TStudent.SetID(Value: string); begin fSTID := Value; end; procedure TStudent.SetName(Value: string); begin fSTName := Value; end; end. unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StudentObj,typinfo; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); var MyStudent : TStudent; PropInfo: PPropInfo; begin MyStudent := TStudent.Create; PropInfo := GetPropInfo(MyStudent.ClassInfo,'STID'); if PropInfo<>nil then begin showmessage('True'); end else begin showmessage('False'); end; end; end.各位前輩 我在使用GetPropInfo時,使用別種物件都OK 為什麼用在自訂物件中會出現Access Violation ?? 我的TStudent.STID屬性也都放在published區段 還有哪些地方必須要注意的呢?? 請各位先進指教 謝謝 |
ha0009
版主 發表:16 回覆:507 積分:639 註冊:2002-03-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |