自己做控件如TNumEdit
添加属性
property Alignment: TAlignment read FAlignment write SetAlignment default taRightJustify;
继承
procedure TNumEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array[Boolean, TAlignment] of DWORD =
((ES_LEFT, ES_RIGHT, ES_CENTER), (ES_RIGHT, ES_LEFT, ES_CENTER));
begin
inherited CreateParams(Params);
with Params do Style := Style or Alignments[UseRightToLeftAlignment, FAlignment];
end;
实现
procedure TNumEdit.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;