一般地,文字和编辑框的边界是靠都比较拢的,如果希望边界宽一点儿,可以使用下面的代码:
procedure TForm1 . Button1Click ( Sender : TObject );
const
BORDER_WIDTH = 20 ;
var
Rect : TRect ;
begin
SendMessage ( Memo1 . Handle , EM_GETRECT , 0 , Longint (@ Rect ));
Rect . Top := BORDER_WIDTH ;
Rect . Left := BORDER_WIDTH ;
Rect . Right := Memo1 . Width - BORDER_WIDTH ;
Rect . Bottom := Memo1 . Height - BORDER_WIDTH ;
SendMessage ( Memo1 . Handle , EM_SETRECT , 0 , Longint (@ Rect ));
Memo1 . Refresh ;
end ;