CnPack Forum


 
Subject: TCnButtonEdit 组件的 ButtonVisible 与 Alignment 属性的配合BUG
gaoyanan (高亚男)
普通灌水员
Rank: 2



UID 39457
Digest Posts 0
Credits 62
Posts 22
点点分 62
Reading Access 10
Registered 2008-4-1
Status Offline
Post at 2010-10-20 13:15  Profile | Blog | P.M.  | QQ
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
Top
 




All times are GMT++8, the time now is 2024-11-22 01:18

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.010449 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP