全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1649
推到 Plurk!
推到 Facebook!

property editor 的建立方式請教

尚未結案
bill534
一般會員


發表:38
回覆:51
積分:17
註冊:2007-02-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-09-08 16:31:19 IP:220.130.xxx.xxx 訂閱
Dear sir
我目前在設計一個元件,但我想讓它在designing期間我可以double click元件icon讓它顯示出一個設定窗來做初使值的設定,但一直找不到sample來參考,有那位大大可以指導一下嗎!感恩喔!
pedro
尊榮會員


發表:152
回覆:1187
積分:892
註冊:2002-06-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-09-09 11:04:53 IP:60.248.xxx.xxx 未訂閱
一般delphi內建的資料型態,ide皆能呼叫對應的屬性編輯器
要自定特殊編輯器,需在Register程序裡用RegisterComponentEditor向IDE註冊

不知道您要做的是什麼型態的屬性編輯器? 如果有進一步的想法,提出來,讓大家幫您想想辦法

下面片斷是我根據
http://delphi.about.com/od/vclusing/a/customvcldev.htm
剛才試驗的程式碼

[code delphi]
type
TLineDirection = (drLeftRight,
drUpDown,
drTopLeftBottomRight,
drTopRightBottomLeft);

TMyTestControl = class(TGraphicControl)
private
{ Private declarations }
FLineDir: TLineDirection;

function GetLineWidth: Integer;
function GetLineColour: TColor;
procedure SetLineWidth(const NewWidth: Integer);
procedure SetLineColour(const NewColour: TColor);
procedure SetLineDir(const NewDir: TLineDirection);
protected
{ Protected declarations }
public
{ Public declarations }
published
property Direction: TLineDirection read FLineDir write SetLineDir;
property LineColour: TColor read GetLineColour write SetLineColour;
property LineWidth: Integer read GetLineWidth write SetLineWidth;
end;

procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyTestControl]);
end;

{ TLine }
function TMyTestControl.GetLineColour: TColor;
begin
Result := Canvas.Pen.Color;
end;

function TMyTestControl.GetLineWidth: Integer;
begin
Result := Canvas.Pen.Width;
end;

procedure TMyTestControl.SetLineColour(const NewColour: TColor);
begin
if NewColour <> Canvas.Pen.Color then
begin
Canvas.Pen.Color := NewColour;
Invalidate;
end;
end;

procedure TMyTestControl.SetLineDir(const NewDir: TLineDirection);
begin
if NewDir <> FLineDir then
begin
FLineDir := NewDir;
Invalidate;
end;
end;

procedure TMyTestControl.SetLineWidth(const NewWidth: Integer);
begin
if NewWidth <> Canvas.Pen.Width then
begin
Canvas.Pen.Width := NewWidth;
Invalidate; // redraws the component
end;
end;

[/code]


進一步資料吸收,請參考
http://delphi.ktop.com.tw/board.php?cid=30&fid=71&tid=22211
http://www.drbob42.com/delphi/property.htm
bill534
一般會員


發表:38
回覆:51
積分:17
註冊:2007-02-22

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-09-09 13:11:51 IP:220.130.xxx.xxx 訂閱
我要一個類似TTreeView元件可以用來編輯預設樹狀圖的Form,我想把它改成用來建一個預設的Ini檔架構,配合TParams來用!!
系統時間:2024-04-20 0:54:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!