edit组件中显示的文字,如何让它居中或者居右对齐啊! edit组件中显示的文字,如何让它居中或者居右对齐啊!不胜感谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对着控件单击右键,有个 position 属性 procedure TForm1.FormCreate(Sender: TObject);begin SetWindowLong(Edit1.Handle, GWL_STYLE, GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中 Edit1.Refresh; SetWindowLong(Edit2.Handle, GWL_STYLE, GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右 Edit2.Refresh;end; var defstyle: dWord;begin defstyle := GetWindowLong(Edit1.Handle, GWL_STYLE); SetWindowLong(Edit1.Handle, GWL_STYLE, defstyle or ES_RIGHT)end; 重载,自己写[转]:将下面控件安装到你的delphi中就行了--------------------------------------unit AEdit;interfaceuses Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls, ExtCtrls;type TEoCEdit = class(TEdit) private { Private declarations } FAlignment: TAlignment; protected { Protected declarations } function GetAlignment: TAlignment; virtual; procedure SetAlignment(newValue: 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; { TEoCEdit }procedure Register;implementationfunction TEoCEdit.GetAlignment: TAlignment;{ Returns the value of data member FAlignment. }begin GetAlignment := FAlignment;end; { GetAlignment }procedure TEoCEdit.SetAlignment(newValue: TAlignment);{ Sets data member FAlignment to newValue. }begin if FAlignment <> newValue then begin FAlignment := newValue; if not (csLoading in componentstate) then ReCreateWnd; end;end; { SetAlignment }destructor TEoCEdit.Destroy;begin inherited Destroy;end; { Destroy }constructor TEoCEdit.Create(AOwner: TComponent);{ Creates an object of type TEoCEdit, and initializes properties. }begin inherited Create(AOwner); { Initialize properties with default values: } FAlignment := taLeftJustify;end; { Create }procedure TEoCEdit.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('EoC', [TEoCEdit]);end; { Register }end. 这段代码行 procedure TForm1.FormCreate(Sender: TObject);begin SetWindowLong(Edit1.Handle, GWL_STYLE, GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中 Edit1.Refresh; SetWindowLong(Edit2.Handle, GWL_STYLE, GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右 Edit2.Refresh;end; delphi 2010 dbgrideh EhLib5.0.13 导出文件出错 求救,十六进制转换的问题!~急死了 变量释放之后已经打开的OLE是否由系统控制? 大家新年快乐!热烈欢迎Delphi中高级程序员加入我公司! 请问有关程序中帮助文件的问题 edit的特殊功能? 请问INDY里的IDFTP控件的什么方法是用于断点续传的! DELPHI程序作成后如何打包? 在Win32API中有否一个只选择目录名的API 子窗口选择的问题请教 请问哪里有DBGried控件详细使用方法的书籍? 关于SQLDataset控件执行CreateTable SQL语言的问题。。。
begin
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中
Edit1.Refresh; SetWindowLong(Edit2.Handle, GWL_STYLE,
GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右
Edit2.Refresh;
end;
defstyle: dWord;
begin
defstyle := GetWindowLong(Edit1.Handle, GWL_STYLE);
SetWindowLong(Edit1.Handle, GWL_STYLE, defstyle or ES_RIGHT)
end;
[转]:将下面控件安装到你的delphi中就行了
--------------------------------------
unit AEdit;interfaceuses
Windows,
SysUtils,
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
Menus,
StdCtrls,
ExtCtrls;type
TEoCEdit = class(TEdit)
private
{ Private declarations }
FAlignment: TAlignment;
protected
{ Protected declarations }
function GetAlignment: TAlignment; virtual;
procedure SetAlignment(newValue: 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; { TEoCEdit }procedure Register;implementationfunction TEoCEdit.GetAlignment: TAlignment;
{ Returns the value of data member FAlignment. }
begin
GetAlignment := FAlignment;
end; { GetAlignment }procedure TEoCEdit.SetAlignment(newValue: TAlignment);
{ Sets data member FAlignment to newValue. }
begin
if FAlignment <> newValue then
begin
FAlignment := newValue;
if not (csLoading in componentstate) then ReCreateWnd;
end;
end; { SetAlignment }destructor TEoCEdit.Destroy;
begin
inherited Destroy;
end; { Destroy }constructor TEoCEdit.Create(AOwner: TComponent);
{ Creates an object of type TEoCEdit, and initializes properties. }
begin
inherited Create(AOwner);
{ Initialize properties with default values: }
FAlignment := taLeftJustify;
end; { Create }procedure TEoCEdit.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('EoC', [TEoCEdit]);
end; { Register }end.
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中
Edit1.Refresh; SetWindowLong(Edit2.Handle, GWL_STYLE,
GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右
Edit2.Refresh;
end;