delphi 编程技巧

源代码在线查看: 一个能罢放控件的statusbar (2001年3月2日).txt

软件大小: 774 K
上传用户: zyhunicom
关键词: delphi 编程技巧
下载地址: 免注册下载 普通下载 VIP

相关代码

				一个能罢放控件的statusbar (2001年3月2日) 
				
				网友更新  分类:数据库   作者:George  推荐:GeorgeAPI   阅读次数:355  
				(http://www.codesky.net)  
				
				--------------------------------------------------------------------------------
				unit ggeProgressBar;
				
				interface
				
				uses
				Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
				ComCtrls,dbctrls,db;
				
				type
				TggeProgressBar = class(TProgressBar)
				private
				{ Private declarations }
				FDataLink:TFieldDataLink;
				function GetDataField:String;
				procedure SetDataField(Value:String);
				function GetDataSource:TDatasource;
				procedure SetDataSource(Value:TDatasource);
				function GetField:TField;
				protected
				{ Protected declarations }
				//data link event handle
				procedure DataChange(Sender:TObject);
				public
				{ Public declarations }
				Constructor Create(AOwner:TComponent);override;
				destructor Destroy;override;
				property Field:TField read GetField;
				published
				{ Published declarations }
				property DataField:String read GetDataField write SetDataField;
				property DataSource:TDataSource read GetDatasource write SetDataSource;
				end;
				
				procedure Register;
				
				implementation
				
				procedure Register;
				begin
				RegisterComponents('win32', [TggeProgressBar]);
				end;
				
				{ TggeProgressBar }
				
				constructor TggeProgressBar.Create(AOwner: TComponent);
				begin
				inherited create(AOwner);
				FDatalink:=TFieldDatalink.Create;
				FDatalink.control:=self;
				FDatalink.OnDatachange:=DataChange;
				end;
				
				procedure TggeProgressBar.DataChange(Sender: TObject);
				begin
				if (FDatalink.Fieldnil) and (FDataLink.Field is TNumericField) then
				position:=FDatalink.Field.AsInteger
				else
				position:=Min;
				end;
				
				destructor TggeProgressBar.Destroy;
				begin
				FDatalink.Free;
				FDatalink:=nil;
				inherited Destroy;
				end;
				
				function TggeProgressBar.GetDataField: String;
				begin
				Result:=FDataLink.FieldName;
				end;
				
				function TggeProgressBar.GetDataSource: TDatasource;
				begin
				Result:=FDatalink.Datasource;
				end;
				
				function TggeProgressBar.GetField: TField;
				begin
				Result:=FDataLink.Field;
				end;
				
				procedure TggeProgressBar.SetDataField(Value: String);
				begin
				FDataLink.FieldName:=Value;
				end;
				
				procedure TggeProgressBar.SetDataSource(Value: TDatasource);
				begin
				FDatalink.Datasource:=Value;
				end;
				
				end.  
				 
							

相关资源