各位大富翁,请问那有可以设置背景透明、可文字左右中对齐的TEdit增强控件???(100分)

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

ZZHI

Unregistered / Unconfirmed
GUEST, unregistred user!
最好能有源码。
 
有人能编出来吗???最好能具有Layout属性。[:)]
 
去 www.vclxx.org 查查
 
使文字具有左、中、右对齐属性的Edit控件挺多,自己实现也不难,但要具有Transparent和Layout这样属性的,
需要从TControl类继承,难度太大:(
下面这个是我试着做的,已经可以实现文字的左、中、右对齐了,你看看吧

unit EditEh;

interface

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

type
TEditEh = class(TCustomEdit)
private
FAlignment: TAlignment;
procedure SetAlignment(Value: TAlignment);
protected
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Alignment: TAlignment read FAlignment write SetAlignment
default taLeftJustify;
property Height;
property Anchors;
property AutoSelect;
property AutoSize;
property BiDiMode;
property BorderStyle;
property CharCase;
property Color;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property ImeMode;
property ImeName;
property MaxLength;
property OEMConvert;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('MyLab', [TEditEh]);
end;

{ TEditEh }

constructor TEditEh.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;

procedure TEditEh.CreateParams(var Params: TCreateParams);
const
Alignments: array [TAlignment] of DWord = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited CreateParams(Params);
CreateSubClass(Params, 'EDITEH');
with Params do
Style := Params.Style or ES_MULTILINE or Alignments[FAlignment];
end;

destructor TEditEh.Destroy;
begin
inherited Destroy;
end;

procedure TEditEh.SetAlignment(Value: TAlignment);
var
OldHeight: Integer;
begin
if FAlignment <> Value then
begin
OldHeight := Height;
FAlignment := Value;
RecreateWnd;
Height := OldHeight;
end;
end;

end.
 
多谢各位!!!
左、中、右对齐属性的TEdit控件多较多,容易完成,可以不提了。
[red]关键是具有Transparent和Layout属性的TEdit控件[/red],就很难找到。

在其他语言中,像VB自还控件中就有这此属性,像我一样的刚入门的人,就觉得
用起来很好,可息,Delphi中就是找不到。

[gold]看来只有请各位高手显显身手!!![/gold]
 
算了,没人回答就散分了,只好等下再问一次了,烦!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
774
import
I
后退
顶部