開發ocx元件時,如何加入icon |
答題得分者是:l630521
|
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
|
l630521
資深會員 發表:15 回覆:349 積分:372 註冊:2003-02-17 發送簡訊給我 |
|
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
|
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
試了一下,現將詳細方法列出
假設OCX物件名稱 TImgTestX 如下 TImgTestX = class(TActiveForm, IImgTestX)
1、在ImgTestImpl1.pas的implementation下,新增一行
{$R ImgTestProj1_TLB.dcr} 2、開啟Delphi的 Image Editor 工具
3、新增一個 .dcr 檔案
4、在 dcr 裡新增一個 Bitmap (建議 16x16 256色)
5、將 Bitmap1 名稱,改為同物件名 TImgTestX
6、編輯好圖形後,另存新檔為 ImgTestProj1_TLB.dcr 這樣就行了,供各位參考、參考
|
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
剛又特地試了一下,發現上面說的方式並不正確
以 ActiveX Form 來說,不過我想其他 ActiveX 物件應該也是一樣 因為無論如何的改 .dcr 裡的圖,從新註冊後其結果仍一樣
在一直的測試下才發現,其實ActiveX 的icon 與 .dcr 無關(在開發過程)
至於改的地方,應該是在 專案.res 檔。
1、先關閉 Delphi
2、以 Image Editor開啟 專案.res
3、在預設的ICON下方,再新增一個Bitmap
4、記得在新增 Bitmap 後,所產生的名稱用 1
至於為何用 1 ,我也不清楚,不過至少用物件名稱是不行的
5、編輯完圖形後,記得存檔
6、重新開啟專案(此時新的 .res 檔,會被載入)
7、從新編輯 ocx ,並註冊即完成 至於先前提的在 implementation下,新增一行 .dcr,這個部份是不需要的
也就是說,在開發發過程中 icon存在於.res不在.dcr。一旦在delphi新增
此ocx元件後,則會自動產生一個 .dcr(裡面就是ICON)。
各位若有興趣可以試試
謝謝
|
l630521
資深會員 發表:15 回覆:349 積分:372 註冊:2003-02-17 發送簡訊給我 |
慚愧!昨天因為只試了一下,沒有再詳細的測試,以為只要圖示出來就對了,今天照了robert1014的方法試了一下,他只用的方法才是正確的,至於為何
4、記得在新增 Bitmap 後,所產生的名稱用 1
至於為何用 1 ,我也不清楚,不過至少用物件名稱是不行的
那是因為在ImgTestImpl1.pas內
initialization TActiveXControlFactory.Create( ComServer, TButtonX, TButton, Class_ButtonX, 3, '', 0, tmApartment);內的紅色3,和.res內的圖示數字相符 TActiveXControlFactory的語法 Creates and initializes a new TActiveXControlFactory object. constructor Create(ComServer: TComServerObject; ActiveXControlClass: TActiveXControlClass; WinControlClass: TWinControlClass; const ClassID: TGUID; ToolboxBitmapID: Integer; const LicStr: string; MiscStatus: Integer); ThreadingModel: TThreadingModel; Description The ComServer parameter is a pointer to the COM server object for the module containing the property page factory. This is normally a global variable, ComServer, declared in the ComServ unit. The ActiveXControlClass parameter is the class object for the controller object that implements the ActiveX control. This object should be derived from TActiveXControl. The WinControlClass parameter is the class object for the VCL control class that implements the Windows behavior of the control. This object should be derived from TWinControl. The ClassID parameter is the GUID of the ActiveX control. Each COM object should have a unique GUID. LicStr is the license string for controls created with this factory. LicStr is empty if controls created with this factory are unlicensed. MiscStatus are the status bits that are stored in the registry. ThreadingModel specifies how calls to the created ActiveX control are serialized. This determines the value of the ThreadingModel property. 最後再一次抱歉,沒有測試完全就Post上答案! Ian |
robert1014
初階會員 發表:34 回覆:85 積分:43 註冊:2002-03-13 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |