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

TStringProperty 的問題

缺席
Yomigae
一般會員


發表:2
回覆:2
積分:0
註冊:2002-06-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-06 14:16:07 IP:218.167.xxx.xxx 未訂閱
Dear all:    這兒有一段設計元件的程式,我開放了一個 aString 的屬性,本來是預期在 Object Inspector 裡連按 aString 的屬性時會開起對話視窗,可是卻沒有,我覺得可能是呼叫 RegisterPropertyEditor 時出現了問題,我是用 BCB6 編譯,希望有人能幫忙解惑,謝謝。
//---------------------------------------------------------
class PACKAGE TSxStringProperty: public TStringProperty
{
public:
    virtual TPropertyAttributes __fastcall GetAttributes()
    {
        return TPropertyAttributes()FileName;
        }
        delete OpenDialog;
    }
};
//---------------------------------------------------------
class PACKAGE TSxWinControl: public TWinControl
{
private:
    AnsiString FString;
protected:
public:
    __fastcall TSxWinControl(TComponent* Owner);
__published:
    __property AnsiString aString={read=FString.write=SetString};
};
//---------------------------------------------------------
TTypeInfo* __fastcall AnsiStringTypeInfo()
{
        TTypeInfo* TypeInfo=new TTypeInfo();
        TypeInfo->Name="AnsiString";
        TypeInfo->Kind=tkLString;
        return TypeInfo;
}
//---------------------------------------------------------
namespace Sxwincontrol
{
    void __fastcall PACKAGE Register()
    {
        RegisterPropertyEditor(AnsiStringTypeInfo(),
            __classid(TSxWinControl),"aString",
            __classid(TSxStringProperty));            TComponentClass classes[1]={__classid(TSxWinControl)};
        RegisterComponents("Sx",classes,0);
    }
}
//---------------------------------------------------------
發表人 - yomigae 於 2003/10/06 14:20:30 發表人 - Gemi0305 於 2003/10/06 15:30:57
Yomigae
一般會員


發表:2
回覆:2
積分:0
註冊:2002-06-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-06 14:59:19 IP:218.167.xxx.xxx 未訂閱
已經在網路上找到答案了,辛苦各位了。 In addition to this, registering AnsiString property editors is not straight forward. The easiest ways to do this is in your Register procedure get the TypeInfo from the property itself since you can't get it from the AnsiString class. Something like TPropInfo *PropInfo = ::GetPropInfo(__typeinfo(TMyComponent), "MyString"); RegisterPropertyEditor(*PropInfo->PropType, __classid(TMyComponent), "MyString", __classid(TMyStringPropEditor));
系統時間:2024-05-15 10:57:15
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!