请问如何使edit编辑框里的字靠右?(10分)

  • 主题发起人 主题发起人 zhbruce
  • 开始时间 开始时间
Z

zhbruce

Unregistered / Unconfirmed
GUEST, unregistred user!
edit编辑框里的字默认是靠左的。。如何使edit编辑框里的字靠右?
thank
 
这个问题才10分呀,别说还真不好回答!
 
代码:
{*******************************************************}
{                                                       }
{              我的编辑框居中版本 1.0.0.0               }
{                   瓦匠泥实用系列                      }
{               Create by Nizvoo Kensen                 }
{                                                       }
{              Copyright (c) 2002 技术笔录              }
{                    2002-07-11                         }
{*******************************************************}

unit MyEdit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TMyEdit = class(TEdit)
  private
    { Private declarations }
    FAlignment: TAlignment;
  protected
    { Protected declarations }
    function GetAlignment: TAlignment; virtual;
    procedure SetAlignment(Value: TAlignment); virtual;
    procedure CreateParams(var Params: TCreateParams); override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    { Published properties and events }
    property Alignment: TAlignment read GetAlignment write SetAlignment;  { Published }
  end;  { TMyEdit }

procedure Register;

implementation

function TMyEdit.GetAlignment: TAlignment;
begin
  GetAlignment := FAlignment;
  {返回当前的状态是居中,左靠,右靠}
end;

procedure TMyEdit.SetAlignment(Value: TAlignment);
begin
  {设置当前的状态是居中,左靠,右靠}
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    if not (csLoading in componentstate) then ReCreateWnd;
  end;
end;

destructor TMyEdit.Destroy;
begin
  inherited Destroy;
end;

constructor TMyEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  {初始化一个预选值}
  FAlignment := taLeftJustify;
end;  { Create }

procedure TMyEdit.CreateParams(var Params: TCreateParams);
const
  Alignments: array[TAlignment] of WORD = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or Alignments[FAlignment];
end;

procedure Register;
begin
  RegisterComponents('Standard', [TMyEdit]);
end;  {注册}

end.
 
贴出来乱七八糟。应该可以。

新建一个pas文件。然后安装控件

在Standard
 
接受答案了.
 
后退
顶部