delphi 中如何设置 Button 的 Caption 文字的对齐方式

来源:互联网 发布:动漫美工招聘要求 编辑:程序博客网 时间:2024/05/15 01:06

delphi  的 TButton 控件的 Caption 文字默认是居中对齐,并且没有提供设置对齐方式的属性和方法,那么如何让Caption 文字左对齐或者右对齐呢?通过调用 API 函数可以实现:

var

  Style: Integer;

begin

  Style := GetWindowLong(btn1.Handle,   GWL_STYLE);

  Style := Style or BS_LEFT;

  SetWindowLong(btn1.Handle, GWL_STYLE, Style);

end;