导航
  • 主页
  • 招聘
  • 语言基础/算法/系统设计
  • 数据库相关
  • 图形处理/多媒体
  • 网络通信/分布式开发
  • VCL组件开发及应用
  • Windows SDK/API
  • 问答

找控件

武稀松 2002-02-05 11:27:42
sncCurrencyEdit控件那里有?
给个链接或发到我的信箱wr_960204@x263.net
...全文
31 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wave_calmly 2002-02-06
http://202.96.70.228/cakk/delphi/
回复
武稀松 2002-02-06
呵呵,这是你自己写的吧。我要的不是这个!
回复
torble 2002-02-05
Source Code for TCurrencyEdit


Unit CurrEdit;



Interface



uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,

Menus, Forms, Dialogs, StdCtrls;



type

TCurrencyEdit = class(TCustomMemo)

private

DispFormat: string;

FieldValue: Extended;

procedure SetFormat(A: string);

procedure SetFieldValue(A: Extended);

procedure CMEnter(var Message: TCMEnter); message CM_ENTER;

procedure CMExit(var Message: TCMExit); message CM_EXIT;

procedure FormatText;

procedure UnFormatText;

protected

procedure KeyPress(var Key: Char); override;

procedure CreateParams(var Params: TCreateParams); override;

public

constructor Create(AOwner: TComponent); override;

published

property Alignment default taRightJustify;

property AutoSize default True;

property BorderStyle;

property Color;

property Ctl3D;

property DisplayFormat: string read DispFormat write SetFormat;

property DragCursor;

property DragMode;

property Enabled;

property Font;

property HideSelection;

property MaxLength;

property ParentColor;

property ParentCtl3D;

property ParentFont;

property ParentShowHint;

property PopupMenu;

property ReadOnly;

property ShowHint;

property TabOrder;

property Value: Extended read FieldValue write SetFieldValue;

property Visible;

property OnChange;

property OnClick;

property OnDblClick;

property OnDragDrop;

property OnDragOver;

property OnEndDrag;

property OnEnter;

property OnExit;

property OnKeyDown;

property OnKeyPress;

property OnKeyUp;

property OnMouseDown;

property OnMouseMove;

property OnMouseUp;

end;



procedure Register;



implementation



procedure Register;

begin

RegisterComponents('Additional', [TCurrencyEdit]);

end;



constructor TCurrencyEdit.Create(AOwner: TComponent);

begin

inherited Create(AOwner);

AutoSize := True;

Alignment := taRightJustify;

Width := 121;

Height := 25;

DispFormat := '$,0.00;($,0.00)';

FieldValue := 0.0;

AutoSelect := False;

WantReturns := False;

WordWrap := False;

FormatText;

end;



procedure TCurrencyEdit.SetFormat(A: String);

begin

if DispFormat <> A then

begin

DispFormat:= A;

FormatText;

end;

end;



procedure TCurrencyEdit.SetFieldValue(A: Extended);

begin

if FieldValue <> A then

begin

FieldValue := A;

FormatText;

end;

end;



procedure TCurrencyEdit.UnFormatText;

var

TmpText : String;

Tmp : Byte;

IsNeg : Boolean;

begin

IsNeg := (Pos('-',Text) > 0) or (Pos('(',Text) > 0);

TmpText := '';

For Tmp := 1 to Length(Text) do

if Text[Tmp] in ['0'..'9','.'] then

TmpText := TmpText + Text[Tmp];

try

FieldValue := StrToFloat(TmpText);

if IsNeg then FieldValue := -FieldValue;

except

MessageBeep(mb_IconAsterisk);

end;

end;



procedure TCurrencyEdit.FormatText;

begin

Text := FormatFloat(DispFormat,FieldValue);

end;



procedure TCurrencyEdit.CMEnter(var Message: TCMEnter);

begin

SelectAll;

inherited;

end;



procedure TCurrencyEdit.CMExit(var Message: TCMExit);

begin

UnformatText;

FormatText;

Inherited;

end;



procedure TCurrencyEdit.KeyPress(var Key: Char);

begin

if Not (Key in ['0'..'9','.','-']) Then Key := #0;

inherited KeyPress(Key);

end;



procedure TCurrencyEdit.CreateParams(var Params: TCreateParams);

begin

inherited CreateParams(Params);

case Alignment of

taLeftJustify : Params.Style := Params.Style or ES_LEFT and Not ES_MULTILINE;

taRightJustify : Params.Style := Params.Style or ES_RIGHT and Not ES_MULTILINE;

taCenter : Params.Style := Params.Style or ES_CENTER and Not ES_MULTILINE;

end;

end;



End.




回复
武稀松 2002-02-05
没人用过吗?
回复
发动态
发帖子
Delphi
创建于2007-08-02

4802

社区成员

Delphi 开发及应用
申请成为版主
社区公告
暂无公告