想置成居中,但是没有对齐方式这个属性。
又或者有没有好的替代方法?(不想有空格)
用TMemo的话,显示效果不好。
Delphi6
又或者有没有好的替代方法?(不想有空格)
用TMemo的话,显示效果不好。
Delphi6
解决方案 »
- idhttp 网页附件上传问题
- EmbeddedWB(WebBrowser)怎么响应网页里的按钮点击事件,响应到delphi中我的自编函数
- 【开帖送分】学到了感兴趣的东西,散分!请sirous (烦) 来接分!
- 把一个MDI风格的窗体封装在一个DLL里,但是调用出错
- 什么控件可以实现三态按钮?
- installshield制作安装程序,如何添加系统搜索路径?
- 高手看看如下sql语句在delphi中运行为什么会出错?
- fastreport 4.8 如何動態設置紙張方向和自定義紙張大小
- 一个问题,关于COMBOBOX。。。。。。。
- 如何控制消息框的显示时间?
- 在Table中密码的输入
- 关于数据库和TreeView之间的问题,(一定给分)
TEditTextAlignment = (etaLeft, etaCenter, etaRight);procedure ResetAlignment(EditHandle: THandle; FTextAlignment: TEditTextAlignment);
var
EditStyle: integer;
begin
EditStyle := GetWindowLong(EditHandle, GWL_STYLE);
case FTextAlignment of
etaLeft : EditStyle := EditStyle or ES_LEFT and (not ES_CENTER) and (not ES_RIGHT);
etaCenter : EditStyle := EditStyle and (not ES_LEFT) or ES_CENTER and (not ES_RIGHT);
etaRight : EditStyle := EditStyle and (not ES_LEFT) and (not ES_CENTER) or ES_RIGHT;
end;
SetWindowLong(EditHandle, GWL_STYLE, EditStyle);
end;
最好自己继承TEdit做个有这功能的控件. 事实上很简单的.
unit JackEdit;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TKeySet = (ksReturn, ksEscape);
TKeySets = set of TKeySet; TJackEdit = class(TEdit)
private
{ Private declarations }
FAlignment: TAlignment;
FKeys: TKeySets; procedure SetAlignment(value: TAlignment);
protected
{ Protected declarations }
procedure CreateParams(var Params: TCreateParams); override;
procedure KeyPress(var Key: Char); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property Keys: TKeySets read FKeys write FKeys;
end;
procedure Register;implementationprocedure TJackEdit.SetAlignment(value: TAlignment);
begin
if value <> FAlignment then
begin
FAlignment := value;
RecreateWnd;
end;
end;procedure TJackEdit.KeyPress(var Key: Char);
begin
if ksReturn in Keys then
begin
if Key = Chr(Vk_Return) then
begin
Key := Chr(0);
(Owner as TControl).Perform(wm_NextDlgCtl,0,0);
end;
end;
if ksEscape in Keys then
begin
if Key = Chr(Vk_Escape) then
begin
Key := Chr(0);
(Owner as TControl).Perform(wm_NextDlgCtl,1,0);
end;
end;
inherited KeyPress(Key);
end;procedure TJackEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
case Alignment of
taLeftJustify : Params.Style := Params.Style or (ES_LEFT or Es_MULTILINE);
taRightJustify : Params.Style := Params.Style or (ES_RIGHT or ES_MULTILINE);
taCenter : Params.Style := Params.Style or (ES_CENTER or Es_MULTILINE);
end;
end;constructor TJackEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAlignment := taLeftJustify;
end;destructor TJackEdit.Destroy;
begin
inherited Destroy;
end;procedure Register;
begin
RegisterComponents('Jack', [TJackEdit]);
end;end.
-------------------------------------
如果您觉的您对Delpih感兴趣或是很想学的更好些或者是对Delphi有更深的认识,我们可以一起交流;
呵呵
www.nxrs.net/bbs
谢谢,别抛砖