设计属性编辑器时需引用DsgnIntf.dcu单元(100分)

  • 主题发起人 主题发起人 huangyanming
  • 开始时间 开始时间
H

huangyanming

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi6、delphi7中编写控件时,当设计属性编辑器时需引用DsgnIntf.dcu单元,但这两个版本没有,听说只有delphi5以下有这单元。如果想在D6/D7下设计属性编辑器,应该怎么办?
总是不难,也不易,肯定能解决,因为我下载别的控件单元就 实现了这样的功能。如能指条明路,100分相送!
 
d6,d7將DsgnIntf 分解成兩個文件DesignIntf,DesignEditors, 你將其改成對應的就行了, 下面的英文的說明, 你也可參考下!

The OpenTools API in Delphi has changed considerably over time. For example, the DsgnIntf unit from Delphi 5 has been split into DesignIntf, DesignEditors, and other specific units. Borland has also introduced interfaces to define the sets of methods for each kind of editor. However, most of the simpler examples, such as those presented in this book, compile almost unchanged from earlier versions of Delphi. For more information, you can study the extensive source code in Delphi's /Source/ToolsApi directory. Notice also that with Delphi 6 Update Pack 2 Borland has for the first time shipped a Help file with the documentation of the OpenTools API.
 
将包分成2个,一个是运行包,一个是设计包。所有的 REG 代码放在设计包。设计包的代码比如像下面这样。

unit ZHANGREG;

interface

uses
{$IFDEF VER130}DsgnIntf, {$ELSE}DesignIntf, DesignEditors,{$ENDIF}Classes,Typinfo,DB;

TYPE
TDBStringProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual;
procedure GetValues(Proc: TGetStrProc); override;
end;

TDataFieldProperty = class(TDBStringProperty)
public
function GetDataSourcePropName: string; virtual;
procedure GetValueList(List: TStrings); override;
end;


procedure Register;

implementation

USES Outlook,wiaTile,Gradpan,gwrlr,backup,
ColorBtns,Comm32,BestWiatile ,CrossDataSet,
Encryp,DsPanel,Trayicon,SPComm,ping,DBStatusBar,
OLItemsProp,DBEditMS,ObjectDataset;


{ TDBStringProperty }

function TDBStringProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;

procedure TDBStringProperty.GetValueList(List: TStrings);
begin
end;

procedure TDBStringProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
begin
Values := TStringList.Create;
try
GetValueList(Values);
for I := 0 to Values.Count - 1 do Proc(Values);
finally
Values.Free;
end;
end;

{ TDataFieldProperty }

function TDataFieldProperty.GetDataSourcePropName: string;
begin
Result := 'OriginalDataSource';
end;

procedure TDataFieldProperty.GetValueList(List: TStrings);
var
DataSource: TDataSource ;
begin
DataSource := GetObjectProp(GetComponent(0), GetDataSourcePropName) as TDataSource;
if (DataSource <> nil) and (DataSource.DataSet <> nil) then
DataSource.DataSet.GetFieldNames(List);
end;

procedure Register;
begin
RegisterComponents('MSTAR', [TOutlook]);
RegisterPropertyEditor (TypeInfo(TOutlookItems),
TOutlook, 'Items', TOLITemsProperty);
RegisterPropertyEditor(TypeInfo(string), TCrossDataSet, 'ColField', TDataFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TCrossDataSet, 'RowField', TDataFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TCrossDataSet, 'DataField', TDataFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TDBStatusPanel, 'DataField', TDataFieldProperty);
RegisterComponents('MSTAR', [TbestwiaTile]);
RegisterComponents('MSTAR', [TwiaTile]);
RegisterComponents('MSTAR', [TGradPan]);
RegisterComponents('MSTAR', [TGridWithRuler]);
RegisterComponents('MSTAR', [TDBGridWithRuler]);
RegisterComponents('MSTAR', [TBackupFile]);
RegisterComponents('MSTAR', [TColor95Button]);
RegisterComponents('MSTAR', [TComm32]);
RegisterComponents('MSTAR', [TTomEncryption]);
RegisterComponents('MSTAR', [TDsPanel]);
RegisterComponents('MSTAR', [TTrayIcon]);
RegisterComponents('MSTAR', [TComm]);
RegisterComponents('MSTAR', [TPing]);
RegisterComponents('Data Controls', [TDBEditMS]);
RegisterComponents('MSTAR', [TCrossDataSet]);
RegisterComponents('MSTAR', [TObjectDataSet]);
RegisterComponents('Data Controls', [TDBStatusBar]);
end;

end.
 
d6,d7 目录下有,加到你的收索路径里去
G:/Borland/Delphi7/Source/ToolsAPI
 
写d6,d7的包,应该养成把是运行时包和设计时包分开的习惯,这样代码也好维护。
 
后退
顶部