線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:996
推到 Plurk!
推到 Facebook!

通過元件的組件編輯器設置的元件屬性為何沒有寫入CFM文件

尚未結案
Leway
一般會員


發表:43
回覆:71
積分:22
註冊:2003-07-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-16 20:29:35 IP:218.80.xxx.xxx 未訂閱
type PColorS7 = ^TColorS7REC; TColorS7REC = record Light : WORD; Dark : WORD; Line : WORD; Fill : WORD; Font : WORD; end; type TTMStaticS7 = class(TStaticText) private f_Length: WORD; f_ColorS7: TColorS7REC; published property Length: WORD read f_Length write f_Length; property ColorS7: TColorS7REC read f_ColorS7 write f_ColorS7; //在組件編輯器中設置該屬性 end; procedure TColorDesignEditor.ExecuteVerb(Index: Integer); begin inherited; case Index of 0: begin f_DesignForm:= TColorDesignForm.Create(application); try f_DesignForm.edtLight.Text:= inttostr((Component as TTMStaticS7).ColorS7.Light); f_DesignForm.edtDark.Text:= inttostr((Component as TTMStaticS7).ColorS7.Dark); f_DesignForm.edtLine.Text:= inttostr((Component as TTMStaticS7).ColorS7.Line); f_DesignForm.edtFill.Text:= inttostr((Component as TTMStaticS7).ColorS7.Fill); f_DesignForm.edtFont.Text:= inttostr((Component as TTMStaticS7).ColorS7.Font); if f_DesignForm.showModal = mrOK then begin if Component is TTMStaticS7 then begin (Component as TTMStaticS7).f_ColorS7.Light:= strtoInt(f_DesignForm.edtLight.Text); (Component as TTMStaticS7).f_ColorS7.Dark:= strtoInt(f_DesignForm.edtDark.Text); (Component as TTMStaticS7).f_ColorS7.Line:= strtoInt(f_DesignForm.edtLine.Text); (Component as TTMStaticS7).f_ColorS7.Fill:= strtoInt(f_DesignForm.edtFill.Text); (Component as TTMStaticS7).f_ColorS7.Font:= strtoInt(f_DesignForm.edtFont.Text); end; {if Component is then begin end;} end; finally f_DesignForm.Free; end; end; end;{case} end; 發表人 - Leway 於 2003/12/16 20:41:17
Leway
一般會員


發表:43
回覆:71
積分:22
註冊:2003-07-29

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-17 09:01:22 IP:218.80.xxx.xxx 未訂閱
在設計狀態雙擊控件,跳對話框,在此對話框上設置ColorS7屬性,但是我發現設置的屬性值沒有存入DFM文件中。我的代碼錯在哪裡?
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-17 09:13:28 IP:218.1.xxx.xxx 未訂閱
Record数据类型在Object Inspetor里是显示不出来的(你没发现吗?);能存入DFM的类别是TPersistent
type
  TColorS7REC = class(TPersistent)
  private
    FLight : WORD;
    FDark : WORD;
    FLine : WORD;
    FFill : WORD;
    FFont : WORD;
  protected
    procedure AssignTo(Dest: TPersistent); override;
  published
    property Light : WORD read FLight write FLight;
    property Dark : WORD read FDark write FDark;
    property Line : WORD read FLine write FLine;
    property Font : WORD read FFont write FFont;
  end;      TTMStaticS7 = class(TStaticText)
  private
    f_Length: WORD;
    f_ColorS7: TColorS7REC;
    procedure SetColorS7(const Value: TColorS7REC);
  public
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
  published
    property Length: WORD read f_Length write f_Length;
    property ColorS7: TColorS7REC read f_ColorS7 write SetColorS7;
  end;    procedure Register;
implementation
procedure Register;
begin
  RegisterComponents('wer',[TTMStaticS7]);
end;
{ TTMStaticS7 }    constructor TTMStaticS7.Create(AOwner: TComponent);
begin
  inherited;
  f_ColorS7:=TColorS7REC.Create;
end;    destructor TTMStaticS7.Destroy;
begin
  f_ColorS7.Free;
  inherited;
end;    procedure TTMStaticS7.SetColorS7(const Value: TColorS7REC);
begin
  f_ColorS7.Assign(Value);
end;    { TColorS7REC }    procedure TColorS7REC.AssignTo(Dest: TPersistent);
begin
  TColorS7REC(Dest).Light:=FLight;
  TColorS7REC(Dest).Dark:=FDark;
  TColorS7REC(Dest).Line:=FLine;
  TColorS7REC(Dest).Font:=FFont;
end;
久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听 發表人 - mustapha.wang 於 2003/12/17 09:16:41
------
江上何人初见月,江月何年初照人
系統時間:2024-06-27 1:22:05
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!