H
hongsen
Unregistered / Unconfirmed
GUEST, unregistred user!
如何让TEDIT控件的宽度和其文本的长度一样?
如下代码为何出错?(错误:吃掉一个字符)
procedure TmyEdit.EditChange(Sender: TObject);
var lpSize:Tsize;
strptchar;
begin
strpt:=pchar(text);
GetTextExtentPoint32(
getdc(handle), // handle of device context
@strpt, // address of text string
GetTextLen, // number of characters in string
lpSize // address of structure for string size
);
width:=lpSize.cx;
if width=0 then
width:=2;
end;
如下代码为何出错?(错误:吃掉一个字符)
procedure TmyEdit.EditChange(Sender: TObject);
var lpSize:Tsize;
strptchar;
begin
strpt:=pchar(text);
GetTextExtentPoint32(
getdc(handle), // handle of device context
@strpt, // address of text string
GetTextLen, // number of characters in string
lpSize // address of structure for string size
);
width:=lpSize.cx;
if width=0 then
width:=2;
end;