属性编辑器的问题? 在线等待。。。,快快快。。。 (5分)

  • 主题发起人 主题发起人 迈克老狼
  • 开始时间 开始时间

迈克老狼

Unregistered / Unconfirmed
GUEST, unregistred user!
我刚开始学习控件编程,在控件中添加一个属性编辑器后,在单元中加上designeditors,老是
提问缺少proxy...pas文件,什么原因,我查帮助,propertyEdit好像是在designeditors中,
啊 !
 
‘查找文件’,找到缺少的那个.pas或它的.dcu文件目录,然后程序的编译搜索路径加上这个路径就行了。
 
但是没有找到。。。那个文件,我把硬盘目录都搜索了一边。。。,好像什么也不做。。。,只要
包涵designeditors单元,就有这个提示。。。
 
我曾碰到过。处理方法记不清了。
可能是将designide60.bpl还是delphiide60.bpl包含到包中。
在delphi帮助的教程部分有说明。
 
应该加DesignIDE.dcp加到你的控件包中。

不要在你的Lib Path或是Search Path中加入 ../source/toolapi

就可能通过了。
 
D5下开发的大多数控件都是从TComponentEditor派生的
D5中该类的声明在DsgnIntf中
而在D6中对DsgnIntf作了很多改进,原来DsgnIntf单元所
声明的类分散到多个单元中:DesignIntf、DesignEditors、Design*…………(源代码
位于Source/ToolsAPI中,你可以去对比一下)
所以,对于在D5开发的从TComponentEditor派生的控件,要到D6下使用,需要经过以下
几个步骤:
1、添加 lib/designide.dcp到控件的dpk文件的requires部分
2、在控件的pas源文件中凡是uses DsgnIntf的地方改成uses DesignIntf, DesignEdit
ors
为保证控件可以同时在D5和D6中使用,可以采用条件编译:
uses
{$IFDEF VER140}
DesignIntf, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
经过了这两步,控件应该就可以安装了

 
谢谢各位的帮忙,我按照上面的方法都不行,加上DesignIntf, DesignEditors后,控件倒是
可以安装,但是安装后不能使用,程序老提示没有proxies.duc,我发现是designeditors中
调用了proxies,好像是个代理的什么东西,但是delphi带的例子程序pielib.dpk确没有
这种错误,我看了程序也没发现什么不一样的的地方。我的dpk文件中也包含了designide.dcp
vcl.dcp,vclx.dcp,rtl.dcp,应该不会有露过的地方,下面我把源码贴出来,大家再帮我看下,
另外这儿还有两个问题,1,我重载了create,设置text='',为什么生成的控件text确不为空呢
2,如何从面版上彻底删除自己安装的组件呢,我把dpk中pas文件载编译,好像可以,但这样
太麻烦了,还有没有其他好的办法呢?我的信箱kangdeguo@sohu.com,mikewolf_gkd@sohu.com,mikewolf_gkd@163.com
大家如果有属性编辑器控件的例子请发给我一份 谢谢!!!
unit GGkdEdit;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls,
Graphics, StrUtils,DesignIntf,DesignEditors,Dialogs;//graphics为Tbitmap需要,strUtils为rightstr需要
type

aboutstring= record
name:string;
version:string;
email:string;
end;
//数字编辑框
TNumEdit = class(TEdit)
private
FRollInput: boolean;
FAbout: AboutString;
procedure SetRollInput(const Value: boolean);
procedure SetAbout(const Value: AboutString);
protected
procedure KeyPress(var Key: Char); override;
public
//重载TEdit的创建方法,这是一个构造函数
constructor Create(AOwner:TComponent);override ;
published
//定义是否允许属性编辑框滚动输入属性,缺省为true
property RollInput:boolean read FRollInput write SetRollInput default true;
property About:AboutString read FAbout write SetAbout;
end;
//About的属性编辑器
TAboutProperty = class(TPropertyEditor)
public
procedure Edit;override;
function GetAttributes:TPropertyAttributes;override;
function GetValue:string;override;
end;
procedure Register;

implementation

procedure Register;
begin
RegisterComponents('GControl', [TNumEdit]);
RegisterPropertyEditor(TypeInfo(AboutString),nil,'',TAboutProperty);
end;

{ TNumEdit }

constructor TNumEdit.Create(AOwner: TComponent);
begin
//首先继承TEdit的create
inherited create(AOwner);
//下面为自己添加的代码
//定义缺省的字体,Arial,根据自己的经验,此种字体在各个系统中显示比较整齐
//没有毛边现象
Font.Name:='Arial';
//定义字体的大小,这儿为11,即为5号字
Font.Size:=11;
//设置编辑框初始值为空,因为每次我加入一个编辑框第一件事就是清空它。
Text:='';
//初始可以滚动编辑框
RollInput:=True;
end;

procedure TNumEdit.KeyPress(var Key: Char);
var
cRect:TRect;
bm:TBitmap;
begin
//继承TEdit的keypress处理...
inherited KeyPress(key);
//输入滚动的处理
//如果不为Tab键、回车键、左移方向键、回退键、而且是否滚动属性为false,进行处理
if (not RollInput) and (ord(key)<>VK_TAB) and (ord(key)<>VK_RETURN) and (ord(key)<>VK_LEFT) and (ord(key)<>VK_BACK) then
begin
Windows.GetClientRect(self.Handle,cRect); //获取编辑框的客户区
bm:=TBitmap.Create; //创建一个位图
//设置位图的高度、宽度使和编辑框的高度、宽度相同,设置位图的字体和编即框一样
bm.Width :=cRect.Right;
bm.Height:=cRect.Bottom;
bm.Canvas.Font :=self.Font ;
if bm.Canvas.TextWidth(self.Text+key)>cRect.Right then
//如果超出范围,则把当前字符修改无效字符
key:=#0;
bm.free; //释放位图资源
end;
//不是数字的处理
if ((key<'0') or (key>'9')) and (key<>char(VK_BACK)) then
key:=chr(0);

end;

procedure TNumEdit.SetAbout(const Value: AboutString);
begin
FAbout := Value;
end;

procedure TNumEdit.SetRollInput(const Value: boolean);
begin
FRollInput := Value;
end;

{ TAboutProperty }

procedure TAboutProperty.Edit;
var
msg:string;
begin
inherited;
msg:='TNumEdit组件'+chr(13)+chr(10)+'Edited by 郭康德,2002-08-11';
msg:=msg+chr(13)+chr(10)+'Email:kangdeguo@sohu.com';
Showmessage(msg);
end;

function TAboutProperty.GetAttributes: TPropertyAttributes;
begin
Result:=[paMultiSelect,padialog,paReadOnly];
end;

function TAboutProperty.GetValue: string;
begin
Result:='Click On...for About box';
end;

end.
 
高手麻烦看一下。。。
 
高手看一下。。。
 
多人接受答案了。
 
后退
顶部