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

承繼與 Package 間的合作問題

尚未結案
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-06-24 12:31:59 IP:218.103.xxx.xxx 未訂閱
假如我有三個 Form, 互相有承繼關係的, 例如: TForm1->TForm2->TForm3 (TForm1 是父類別, 相對的 .PAS 檔案為 Unit1, Unit2, Unit3)。我希望把 TForm1 放入一個獨立的 Package1 中, TForm2 放入另一個 Package2 中, 但我不懂得如何把 Package1 加入到 Package2, 於是我在 Package2 中一加入 Unit2, 便會得到錯誤訊息: Error create form: Ancestor for 'TForm1' not found. 我嘗試過把 Package1.dcp 加入到 Package2 project 的 Requires section, 但無效, 也嘗試過把 Package1.bpl 加入到 Package2 project option 中的 Design Packages, 都無法解決這個錯誤。 還有一個問題是 TForm3, 如果我成功地把 Package2 做出來, 我如何把它使用在 TForm3 中, 讓 TForm3 承繼自 Package2 中的 TForm2 呢? 謝謝。 -- 小卜子
------
--
小卜子
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-06-24 12:40:23 IP:147.8.xxx.xxx 未訂閱
You need to build and use runtime package. In Unit2, uses Unit1 and in Unit3 uses Unit2.
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-06-24 12:48:43 IP:218.103.xxx.xxx 未訂閱
引言: You need to build and use runtime package. In Unit2, uses Unit1 and in Unit3 uses Unit2.
但我在 Package2 project 中, Option->Packages 頁中的 Runtime packages 的 Build with runtime packages 的 CheckBox 是 Disabled 的, 為甚麼呢? -- 小卜子
------
--
小卜子
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-06-24 14:15:05 IP:147.8.xxx.xxx 未訂閱
Projects|Options|Descritpion|Usage Options. Better make the package runtime only preventing misuse of it as designtime package. And only .exe needs to be specified whether it should be built with runtime package or not.
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-06-24 14:56:12 IP:218.103.xxx.xxx 未訂閱
引言: Projects|Options|Descritpion|Usage Options. Better make the package runtime only preventing misuse of it as designtime package. And only .exe needs to be specified whether it should be built with runtime package or not.
這個 Runtime packages CheckBox 不是永遠灰了(Disabled)的, 我建立一個 Application project 時, 它是可以讓我 Check 與 Uncheck 的, 但當我建立的是 Package project 時, 卻總是灰了 Runtime packages 選項。 我已嘗試 Projects|Options|Description|Usage了, 怎麼心不能讓 Package project 中的 Runtime packages CheckBox 改為 Eanbled 讓我 Check。 我猜我是要用 Design Time Package 的對嗎? 因為 Unit2 既然要繼承自 Unit1, 那麼 Unit2 中就總是要 uses Unit1 了, 但我不懂得怎樣把 Package1 加進 Package2, 好讓 Unit2 能正確地繼承自 Unit1。 -- 小卜子
------
--
小卜子
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-06-24 16:25:05 IP:147.8.xxx.xxx 未訂閱
Only .exe need the option Build with runtime package..... For package this option is meaningless, hence the disabled check box. I have spent sometime and tried.. can make designtime package. So you will need to use runtime package and you will NOT be able to modify the inherited forms inside the package. You need to create a project including all the forms for editing. Here is a simple demo I created, hope this helps: http://delphi.ktop.com.tw/loadfile.php?TOPICID=16353011&CC=365729 TForm1 in Package1 TForm2 in Package2 inherits from TForm1 in Package1 Project3 is created to EDIT TForm2 only. Project4 is an .exe build with runtime package creating a form: TForm2.
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-06-24 17:31:03 IP:218.103.xxx.xxx 未訂閱
引言: Only .exe need the option Build with runtime package..... For package this option is meaningless, hence the disabled check box. I have spent sometime and tried.. can make designtime package. So you will need to use runtime package and you will NOT be able to modify the inherited forms inside the package. You need to create a project including all the forms for editing. Here is a simple demo I created, hope this helps: http://delphi.ktop.com.tw/loadfile.php?TOPICID=16353011&CC=365729 TForm1 in Package1 TForm2 in Package2 inherits from TForm1 in Package1 Project3 is created to EDIT TForm2 only. Project4 is an .exe build with runtime package creating a form: TForm2.
明白了, 真的很謝謝你。 我知道了, 我其實本來就已成功做到。關鍵在於當把 Unit2 加進 Package2 時, 因為 IDE 未能提供 Unit1 作為 Unit2 的 Ancestor Base, 所以出了 Error, 我便沒做下去了。其實這時我照樣把 Package2 Compile 出來的 .bpl 檔是運作正常的, 而我確實不能在 Package2 的 File tree 的 Unit2 上 Double Click 來打開這張 Form 來 Edit。也是因為同樣的理由, 所以你提醒了我另做一個 Project 來 Maintain 這個 Form, 然後回到 Package2 project 來 Compile, 這個提醒很有用, 把難題一下子明朗化了。 -- 小卜子
------
--
小卜子
系統時間:2024-06-30 2:57:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!