我想每當 Assign 屬性值時機做些事情 |
尚未結案
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
James
高階會員 ![]() ![]() ![]() ![]() 發表:10 回覆:290 積分:220 註冊:2002-07-25 發送簡訊給我 |
type B = class(TClientDataSet) private function GetDataSource: TDatasource; procedure SetDataSource(const Value: TDatasource); public property MasterSource: TDatasource read GetDataSource write SetDataSource; end ; function B.GetDataSource: TDatasource; begin Result := inherited MasterSource; ShowMessage( 'Get' ); end; procedure B.SetDataSource(const Value: TDatasource); begin Inherited MasterSource := Value ; ShowMessage( 'Set' ); end; |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言:原來 Property 可以 Inherited 的, 現在知道了, 謝謝你。我用了這方法解決了問題了。 -- 小卜子type B = class(TClientDataSet) private function GetDataSource: TDatasource; procedure SetDataSource(const Value: TDatasource); public property MasterSource: TDatasource read GetDataSource write SetDataSource; end ; function B.GetDataSource: TDatasource; begin Result := inherited MasterSource; ShowMessage( 'Get' ); end; procedure B.SetDataSource(const Value: TDatasource); begin Inherited MasterSource := Value ; ShowMessage( 'Set' ); end;
------
-- 小卜子 |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
引言:原來 Property 可以 Inherited 的, 現在知道了, 謝謝你。我用了這方法解決了問題了。There is a potential problem with the above method. You are not overriding the property but actually hiding the inherited one. So when you typecast your object (e.g. TClientDataSet) and set its DataSource property, it is actullay using the TCustomDataSet method, not yours. |
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言:我確未想到這個, 我明白了, 因為無法做到 Late binding 的效果, 那麼請你繼續解說一下 deDataSetChange 的用法好嗎, DB.pas 中牽涉到 deDataSetChange 的程式碼不少, 看不來。 -- 小卜子引言:原來 Property 可以 Inherited 的, 現在知道了, 謝謝你。我用了這方法解決了問題了。There is a potential problem with the above method. You are not overriding the property but actually hiding the inherited one. So when you typecast your object (e.g. TClientDataSet) and set its DataSource property, it is actullay using the TCustomDataSet method, not yours.
------
-- 小卜子 |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言: But you cannot only build your application as runtime packages then and this functionality will not work inside the IDE at design time. And what do you want to do with this change of DataSource?謝謝您。但我不想它受到限制而不能作為 runtime packages。 我正建立一個 TMyClientDataSet, 我希望它能第一時間取得其 Master DataSet 的一些資料。那麼最好的時機, 應該就是當設定另一個 TMyClientDataSet 物件給它作為 Master Table 時 (也就是 Assign value 給它的 MasterSource 屬性時), 一併把 Master DataSet 的那些資料交給它了。 有沒有其他辦法呢? -- 小卜子
------
-- 小卜子 |
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
Diviner
初階會員 ![]() ![]() 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言: If you only what this function in TMyClientDataet then using James's method is fine. Otherwise, I think you need to modify TCustomClientDataSet in the VCL.不是不敢動 VCL, 只是覺得這得配合一些管理工作才行, 否則後人拿起我的 Source code 卻連 Compile 都作不了, 卻沒有很好的 Document 說明時, 他會無計可施呢, 那就很麻煩了。 那權用 James 的方法吧, 謝謝您。 -- 小卜子
------
-- 小卜子 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |