edit文本框中的内容都是左对齐,那个属性能使它右对齐呀!谢谢!
解决方案 »
- 在线等解答 模拟鼠标单击事件
- adoquery执行sp_fkeys存储过程后怎么取得返回值?
- 为防止用户误删数据,我想在操作之前让他输入密码,应该怎么做
- 循环处理的速度为什么会越来越慢?
- 各位 哥哥...帮帮小妹!看dbgridEh怎么实现以下功能!谢了!多谢了!!!!!
- 如何通过程序写批处理文件
- Except: 如何得到方法调用的入口地址?
- 菜鸟提一个简单问题:有两张表MainFrm and OptionFrm,单击表MainFrm 中的按钮button1如何打开表OptionFrm,同时关闭表MainFrm ?
- COM+的问题
- 在DELPHI里面有没有读取时间的函数,其精确到毫秒的??急救。
- 关于TQRGRoup中TQRExpr的合计表达式的用法
- 100分求:钱达智先生<delphi学习笔记>完整版本?
unit adpEdit;interfaceuses
SysUtils, Classes, Controls, StdCtrls, Graphics, Windows, Messages;type
TadpEdit = class(TEdit)
private
FOldBackColor : TColor;
FColorOnEnter : TColor;
FAlignment: TAlignment;
FTabOnEnter: boolean;
procedure SetAlignment(const Value: TAlignment); property OldBackColor : TColor read FOldBackColor write FOldBackColor;
protected
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: Char); override; procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner:TComponent); override;
published
property Alignment : TAlignment read FAlignment write SetAlignment;
property ColorOnEnter : TColor read FColorOnEnter write FColorOnEnter;
property TabOnEnter : boolean read FTabOnEnter write FTabOnEnter;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('delphi.about.com', [TadpEdit]);
end;{ TadpEdit }
procedure TadpEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array[TAlignment] of DWORD = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited CreateParams(Params); with Params do
Style := Style or Alignments[FAlignment];
end; (*CreateParams*)constructor TadpEdit.Create(AOwner: TComponent);
begin
inherited; FColorOnEnter := Color;
Alignment := taLeftJustify;
end; (*Create*)procedure TadpEdit.DoEnter;
begin
OldBackColor := Color;
Color := ColorOnEnter; inherited;
end; (*DoEnter*)procedure TadpEdit.DoExit;
begin
Color := OldBackColor; inherited;
end; (*DoExit*)procedure TadpEdit.SetAlignment(const Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end; (*SetAlignment*)procedure TadpEdit.KeyPress(var Key: Char);
begin
inherited KeyPress(Key); if TabOnEnter AND (Owner is TWinControl) then
begin
if Key = Char(VK_RETURN) then
begin
if HiWord(GetKeyState(VK_SHIFT)) <> 0 then
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 1, 0)
else
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 0, 0);
Key := #0;
end;
end;
end; (*KeyPress*)end. (*adpEdit.pas*)
defstyle: dWord;
begin
defstyle := GetWindowLong(Edit1.Handle, GWL_STYLE);
SetWindowLong(Edit1.Handle, GWL_STYLE, defstyle or ES_NUMBER)
end;
你的ES_RIGHT 參數不好用啊。
-------------------------------------
只能继承edit,重新作。
你了可以试试用其它的控件啊,图标是一个文本框中间写着123的那个控件,或都上网去找几个控件.