由于刚开始学习编写组件,还没入门。所以请兄弟指教:
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;
    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的文字挡掉
      

  2.   


    如果要实现渐变的话  , 看一MSND里CBITMAP比较我麻烦