CnPack Forum » CnVCL 组件包 » TCnButtonEdit 组件的 ButtonVisible 与 Alignment 属性的配合BUG


2010-10-20 13:15 gaoyanan
TCnButtonEdit 组件的 ButtonVisible 与 Alignment 属性的配合BUG

如题!
当:
[color=blue]ButtonVisible  := False;[/color]
[color=blue]Alignment := taRightJustify;[/color]

嘿嘿,文字少了3个半。

我看了一下代码:
[color=blue]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;[/color]

当然,很多地方都调用了这个方法,对于[color=#0000ff]EM_SETRECTNP[/color]消息我不是很熟悉,我查看了一下Raize Components的TRzButtonEdit,他的实现方式类似:
[font=幼圆][size=3]  protected
    procedure SetEditRect; virtual; [/size][/font]

[font=幼圆][size=3]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;[/size][/font]
[font=幼圆][size=3]然后[/size][/font]
[font=幼圆][size=3][/size][/font]
然后覆盖CreateWnd方法。

[font=幼圆][size=3]procedure TGcxCustomEdit.CreateWnd;
begin
  inherited;
  SetEditRect;
end;


[/size][/font]最近在写组件玩,刚好写到Margin属性,互相参考学习一下。
没有尝试修改CnButtonEdit文件,所以也没法做确切的修正,请版主及模块所有者参考下帖修正:
[url=http://gaoyanan.blog.sohu.com/161260637.html]http://gaoyanan.blog.sohu.com/161260637.html[/url]

页: [1]


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.