使用第三方元件簡易說明
1.New a Application,拉幾個元件,畫面如下:
TAcroMultiStreamDD:按右鍵Load,將DDSample.atc載入
TAcroMultiReplacer:DDName要連,SeqNo設'0',SystemCodePage設True
TdxDBTreeList為第三方元件,雙擊它,建立三個columns,分別設定Caption如下圖

2.執行起來的畫面如下,沒有呈現中文的原因,因為它是第三方元件的關係

3.在此Project中,New一個Unit,程式碼如下圖
unit dxClassMethod;//單元名稱自己想怎麼取都可以,要記得要加入此project中
interface
uses
AcroMultiClassMethod;//因為AcroClassMethodStorage存在AcroMultiClassMethod中,所以要uses進來用
implementation
uses
Graphics,Variants,dxExEdtr, dxTL, dxDBCtrl, dxCntner, dxDBTL;//應各人需求,像此例是因為TdxDBTreeList此第三方元件,需要uses以上的unit
//程序名稱可以自己定,下面2邊綠色都一樣即可,至於傳的參數,是固定的
procedure Proc_TdxDBTreeList(ATable:IDataLocate;AComponent:TObject;
ACodePage,ASeqNo:string;AFont:TFont);
var
i:Integer;
begin
//caption要自己置換,呼叫GetDisplayValue這個function,其中黃色部分即為原語,其他參數都不用管
for i:=0 to TdxDBTreeList(AComponent).ColumnCount-1 do
TdxDBTreeList(AComponent).Columns[i].Caption:=
GetDisplayValue(ATable, TdxDBTreeList(AComponent).Columns[i].Caption, ACodePage, ASeqNo);
//如果此段都沒有寫,就不會進行置換動作
end;
initialization
//向DD元件註冊TdxDBTreeList,第二個參數傳一個procedure
AcroClassMethodStorage.RegisterClassMethod(TdxDBTreeList,Proc_TdxDBTreeList);
//上行是向DD元件說,將類別為TdxDBTreeList的元件,將它丟入Proc_TdxDBTreeList中,參數中的AComponent即為那顆元件
finalization
//固定寫法
AcroClassMethodStorage.UnRegisterClassMethod(TdxDBTreeList);
end.
4.執行畫面如下,Columns的Caption會自動轉成繁體中文:

5.建議您也可以直接註冊TdxDBTreeList的父代類別或更上層類別,如下程式碼:
TCustomdxDBTreeList = class(TCustomdxDBTreeListControl)
TdxDBTreeList = class(TCustomdxDBTreeList)
由程式碼得知TdxDBTreeList繼承自TCustomdxDBTreeList,而TCustomdxDBTreeList繼承自TCustomdxDBTreeListControl,
我們在註冊時,可以直接拿TCustomdxDBTreeListControl(TdxDBTreeList的爺爺)來註冊,以後,只要是繼承自
TCustomdxDBTreeListControl的元件,它自己本身不用再註冊了
部分程式如下:
procedure Proc_TdxDBTreeList(ATable:IDataLocate;AComponent:TObject;
ACodePage,ASeqNo:string;AFont:TFont);
var
i:Integer;
begin
for i:=0 to TCustomdxDBTreeListControl(AComponent).ColumnCount-1 do
TCustomdxDBTreeListControl(AComponent).Columns[i].Caption:=
GetDisplayValue(ATable, TCustomdxDBTreeListControl(AComponent).Columns[i].Caption, ACodePage, ASeqNo);
end;
initialization
AcroClassMethodStorage.RegisterClassMethod(TCustomdxDBTreeListControl,Proc_TdxDBTreeList);
finalization
AcroClassMethodStorage.UnRegisterClassMethod(TCustomdxDBTreeListControl);
end.
6.提供Rave報表元件的註冊Demo(Rave為Delphi標準元件,但多語言套件沒有幫他做自動註冊)