Чтение онлайн

ЖАНРЫ

Советы по Delphi. Версия 1.4.3 от 1.1.2001

Озеров Валентин

Шрифт:

 nbCancel : BtnName := 'nbCancel';

 nbRefresh: BtnName := 'nbRefresh';

 end;

 MessageDlg('Была нажата кнопка' + BtnName, mtInformation, [mbOK], 0);

end;

Edit 

Денежное поле редактирования

Delphi 1 

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;

Поделиться с друзьями: