Subject:
TCnButtonEdit 组件的 ButtonVisible 与 Alignment 属性的配合BUG
[Print This Page]
Author:
gaoyanan
Time:
2010-10-20 13:15
Subject:
TCnButtonEdit 组件的 ButtonVisible 与 Alignment 属性的配合BUG
如题!
当:
ButtonVisible := False;
Alignment := taRightJustify;
嘿嘿,文字少了3个半。
我看了一下代码:
procedure TCnButtonEdit.UpdateFormatRect;
var
Rect: TRect;
begin
Rect := ClientRect;
if FButtonVisible then
Dec(Rect.Right, FButton.Height)
else
Inc(Rect.Right, FButton.Height);
SendMessage(Handle, EM_SETRECTNP, 0, Longint(@Rect));
end;
当然,很多地方都调用了这个方法,对于
EM_SETRECTNP
消息我不是很熟悉,我查看了一下Raize Components的TRzButtonEdit,他的实现方式类似:
protected
procedure SetEditRect; virtual;
procedure TGcxCustomEdit.SetEditRect;
begin
if (Handle = 0) or (not Assigned(Self.Parent)) then
Exit;
SendMessage(Handle, EM_SetMargins, EC_LeftMargin, MakeLong(FMargin, 0));
SendMessage(Handle, EM_SetMargins, EC_RightMargin, MakeLong(0, FMargin));
end;
然后
然后覆盖CreateWnd方法。
procedure TGcxCustomEdit.CreateWnd;
begin
inherited;
SetEditRect;
end;
最近在写组件玩,刚好写到Margin属性,互相参考学习一下。
没有尝试修改CnButtonEdit文件,所以也没法做确切的修正,请版主及模块所有者参考下帖修正:
http://gaoyanan.blog.sohu.com/161260637.html
Welcome to CnPack Forum (http://bbs.cnpack.org/)
Powered by Discuz! 5.0.0