由于刚开始学习编写组件,还没入门。所以请兄弟指教:
1、写完组件程序以后不知道如何编译、测试。我每次都是保存程序,然后再把这个组件重新安装。在安装的过程中编译,每改动一次都要装一次,郁闷。有没有好的方法?
2、颜色如何递加? Canvas.Pen.Color := $00a0a0a0;
3、想实现这样一种按钮,就是有背景色、还要渐变的。但是装了以后没反应:unit CoolButton;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Graphics;type
TCoolButton = class(tcustompanel)
private
{ Private declarations } //发布基类属性
procedure SetCaption(const Value: TCaption);
protected
{ Protected declarations }
procedure Paint(); override;
public
{ Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy(); override;
published
{ Published declarations } //发布基类属性
property Caption write SetCaption;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('standard', [TCoolButton]);
end;{ TCoolButton }constructor TCoolButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner); //初始化基类值
Width := 75;
Height := 25; Repaint;
end;destructor TCoolButton.Destroy;
begin inherited;
end;procedure TCoolButton.Paint;
var
IHeight: integer; //IWidth,
begin
inherited;
Canvas.Pen.Color := $00a0a0a0; for IHeight := Top to (Top + Height) do
begin
Canvas.MoveTo(Top, Top + IHeight);
Canvas.LineTo(Top + Width, Top + Width + IHeight);
end;
end;procedure TCoolButton.SetCaption(const Value: TCaption);
begin
inherited Caption := Value;
end;end.
谢谢大家,不胜感激。
1、写完组件程序以后不知道如何编译、测试。我每次都是保存程序,然后再把这个组件重新安装。在安装的过程中编译,每改动一次都要装一次,郁闷。有没有好的方法?
2、颜色如何递加? Canvas.Pen.Color := $00a0a0a0;
3、想实现这样一种按钮,就是有背景色、还要渐变的。但是装了以后没反应:unit CoolButton;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Graphics;type
TCoolButton = class(tcustompanel)
private
{ Private declarations } //发布基类属性
procedure SetCaption(const Value: TCaption);
protected
{ Protected declarations }
procedure Paint(); override;
public
{ Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy(); override;
published
{ Published declarations } //发布基类属性
property Caption write SetCaption;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('standard', [TCoolButton]);
end;{ TCoolButton }constructor TCoolButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner); //初始化基类值
Width := 75;
Height := 25; Repaint;
end;destructor TCoolButton.Destroy;
begin inherited;
end;procedure TCoolButton.Paint;
var
IHeight: integer; //IWidth,
begin
inherited;
Canvas.Pen.Color := $00a0a0a0; for IHeight := Top to (Top + Height) do
begin
Canvas.MoveTo(Top, Top + IHeight);
Canvas.LineTo(Top + Width, Top + Width + IHeight);
end;
end;procedure TCoolButton.SetCaption(const Value: TCaption);
begin
inherited Caption := Value;
end;end.
谢谢大家,不胜感激。
解决方案 »
- 安培了Riase 控件报错:rzcommon was compiled with a different version for graphics .clmenubar
- delphi的uses语句
- delphi 如何屏蔽ctrl+c的复制功能
- 版主来看一下,为什么别人提交的FAQ通过审核后都加信誉分,我怎么不加?
- 两数组的问题?
- P2P打洞的Session可以否1对多个远程NAT的IP?
- 自定义的record数组能不能直接赋值???
- 过滤串问题,不容错过
- PaxScript脚本运行后怎么停止
- 怎样把LONGINT变成INT?
- 我要做一个QuickReport报表的Activex控件,然后嵌到IE里面,这可行吗?我在生成Activex contorl的时候,要选择一个进行包装的VCL构件,要选择
- 一个很奇怪的问题
color:=rgb(random(255),random(255),random(255));
当然,也可 color:=rgb(random(255),random(255), 10 * i);>>3、想实现这样一种按钮,就是有背景色、还要渐变的。但是装了以后没反应:inherited;
Canvas.Pen.Color := $00a0a0a0; for IHeight := Top to (Top + Height) do
begin
Canvas.MoveTo(Top, Top + IHeight);
Canvas.LineTo(Top + Width, Top + Width + IHeight);
end;
这样,估计会将caption的文字挡掉
如果要实现渐变的话 , 看一MSND里CBITMAP比较我麻烦
!