Jump to content

CurrencyEdit


RobYost

Recommended Posts

Thanks.  I made a new control that uses the system configuration of currency if anyone is interested.

 

I'm new to controls, so if you see a problem with this let me know.

 

 

unit UniCurrencyEdit;

interface

uses
  SysUtils, Classes, uniGUIBaseClasses,
  uniGUIClasses, uniEdit;

type

  TUniCurrencyEdit = class(TUniFormattedNumberEdit)
  private
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
  published

  end;

procedure Register;

implementation

constructor TUniCurrencyEdit.Create(AOwner: TComponent);
begin
  inherited;
  case (formatsettings.CurrencyFormat) of
    0:
      begin
        FormattedInput.CurrencySignPos := cpsLeft;
        FormattedInput.CurrencySignSpace := crsNone;
      end;
    1:
      begin
        FormattedInput.CurrencySignPos := cpsRight;
        FormattedInput.CurrencySignSpace := crsNone;
      end;
    2:
      begin
        FormattedInput.CurrencySignPos := cpsLeft;
        FormattedInput.CurrencySignSpace := crsAvailable;
      end;
    3:
      begin
        FormattedInput.CurrencySignPos := cpsRight;
        FormattedInput.CurrencySignSpace := crsAvailable;
      end;

  end;
  FormattedInput.ShowCurrencySign := True;
  FormattedInput.CurrencySign := FormatSettings.CurrencyString;
  ThousandSeparator := FormatSettings.ThousandSeparator;
  DecimalSeparator := FormatSettings.DecimalSeparator;
  Alignment := taRightJustify;
end;

procedure Register;
begin
  RegisterComponents('UniAddOns', [TUniCurrencyEdit]);
end;

end.

Link to comment
Share on other sites

  • 7 months later...

Thanks.  I made a new control that uses the system configuration of currency if anyone is interested.

 

I'm new to controls, so if you see a problem with this let me know.

 

 

unit UniCurrencyEdit;

 

interface

 

uses

  SysUtils, Classes, uniGUIBaseClasses,

  uniGUIClasses, uniEdit;

 

type

 

  TUniCurrencyEdit = class(TUniFormattedNumberEdit)

  private

  protected

    { Protected declarations }

  public

    constructor Create(AOwner: TComponent); override;

  published

 

  end;

 

procedure Register;

 

implementation

 

constructor TUniCurrencyEdit.Create(AOwner: TComponent);

begin

  inherited;

  case (formatsettings.CurrencyFormat) of

    0:

      begin

        FormattedInput.CurrencySignPos := cpsLeft;

        FormattedInput.CurrencySignSpace := crsNone;

      end;

    1:

      begin

        FormattedInput.CurrencySignPos := cpsRight;

        FormattedInput.CurrencySignSpace := crsNone;

      end;

    2:

      begin

        FormattedInput.CurrencySignPos := cpsLeft;

        FormattedInput.CurrencySignSpace := crsAvailable;

      end;

    3:

      begin

        FormattedInput.CurrencySignPos := cpsRight;

        FormattedInput.CurrencySignSpace := crsAvailable;

      end;

 

  end;

  FormattedInput.ShowCurrencySign := True;

  FormattedInput.CurrencySign := FormatSettings.CurrencyString;

  ThousandSeparator := FormatSettings.ThousandSeparator;

  DecimalSeparator := FormatSettings.DecimalSeparator;

  Alignment := taRightJustify;

end;

 

procedure Register;

begin

  RegisterComponents('UniAddOns', [TUniCurrencyEdit]);

end;

 

end.

 

I think must set DecimalUseOSDefault := True on Create.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...