现在想法:是在画布上画个填充矩形,点击(判断click的范围在这个矩形内)后修改填充颜色,表示他的外观的变化。问题是:如何处理button的配置参数面板,就像我们在delphi中的样式,修改一下事件,属性信息,我的想法是做一个参数面板的form,画图窗体f1,和参数窗体f2之间通过传递消息,互相触发form内的函数相应变化。有没有更好的方法?还有我的button在运行的时候也是可以修改属性的。对这样的问题,大家帮我想想该怎么处理好。

解决方案 »

  1.   


    //写入到日志中
    //Duo
    //080701
    unit DuoLog;interfaceuses
      Windows, Forms,Messages, SysUtils, Classes,Dialogs,DuoKitBaseClass;type
      TBeforeDuoLog = procedure(var ALogStr:String) of object;
      TAfterDuoLog = procedure(const AFileName,ALogStr:String) of object;
      TPromptDuoLog = procedure(const APromptStr:String) of object;
      TDuoLog = class(TDuoBase)
      private
        FFileName: TFileName;
        FBeforeLog:TBeforeDuoLog;
        FAfterLog:TAfterDuoLog;
        FAutoNewLine: Boolean;
        FEnabled: Boolean;
        FVersion,FPath: String;
        FOnPrompt: TPromptDuoLog;
        function GetFullFileName: TFileName;
        function GetVersion: String;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        procedure LogIt(AStr:String);
        procedure ResetIt;
      published
        property Version:String read GetVersion write FVersion;
        property FileName:TFileName read FFileName write FFileName;
        property Path:String read FPath write FPath;
        property FullFileName:TFileName read GetFullFileName;
        property OnBeforeLog:TBeforeDuoLog read FBeforeLog write FBeforeLog;
        property OnAfterLog:TAfterDuoLog read FAfterLog write FAfterLog;
        property AutoNewLine:Boolean read FAutoNewLine write FAutoNewLine;
        property Enabled:Boolean read FEnabled write FEnabled;
        property OnPrompt:TPromptDuoLog read FOnPrompt write FOnPrompt;
      end;implementation{ TDuoLog }constructor TDuoLog.Create(AOwner: TComponent);
    begin
      inherited;
      FAutoNewLine:=false;
      FEnabled:=true;
      if csDesigning in ComponentState then
        FPath:=''
      else FPath:=ExtractFilePath(Application.ExeName);
    end;destructor TDuoLog.Destroy;
    begin  inherited;
    end;function TDuoLog.GetFullFileName: TFileName;
    begin
      if FPath<>'' then
        Result:=FPath+FFileName
      else Result:=ExtractFilePath(Application.ExeName)+FFileName;
    end;function TDuoLog.GetVersion: String;
    begin
      Result:='1.2';
    end;procedure TDuoLog.LogIt(AStr: String);
    var F:TextFile;ALogStr:String;
    begin
      if not FEnabled then exit;
      if FFileName='' then exit;
      AssignFile(F,FullFileName);
      if FileExists(FullFileName) then
        Append(F)
      else Rewrite(F);
      ALogStr:=AStr;
      if Assigned(FBeforeLog) then FBeforeLog(ALogStr);
      if FAutoNewLine then
        WriteLn(F,ALogStr)
      else Write(F,ALogStr);
      Flush(F);
      if Assigned(FAfterLog) then FAfterLog(FullFileName,ALogStr);
      CloseFile(F);
    end;procedure TDuoLog.ResetIt;
    var s:String;
    begin
      s:=FullFileName;
      if (s<>'')and FileExists(s) then
      begin
        if DeleteFile(s) and Assigned(FOnPrompt) then FOnPrompt('删除'+s);
      end;
    end;end.
      

  2.   

    TDuoLog = class(TDuoBase)
    改成
    TDuoLog = class(TComponent)
      

  3.   

    画的话不难,canvas.rectangle(x,y,x+30,y+10);之类的就可以类似的出来一个,canvas.textout(x,y,string);可以画一个,如果要求不高的话
    定义这个按钮的属性和事件怎么做?现在没有太好的办法