Membuat Aligment EditBox menjadi rata tengah. di delhpi 7 editbox itu tidak ada di propertynya agar teks menjadi rata tengah, tapi tidak tau kalo ver lain. oleh karena itu ada coding untuk membuat aligmentnya itu rata tengah. ini dia :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TEdit = class(StdCtrls.TEdit)
private
FAlignment : TAlignment;
procedure SetAlignment(Value: TAlignment);
protected
procedure CreateParams(var Params: TCreateParams); override;
public
property Alignment: TAlignment read FAlignment write SetAlignment;
end;
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TEdit.CreateParams(var Params: TCreateParams);
const
Alignments : array[TAlignment] of LongInt = (ES_Left,ES_Right, ES_Center);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or ES_MULTILINE or Alignments[FAlignment];
end;
procedure TEdit.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Alignment := taCenter;
end;
end.
0 comments:
Post a Comment
Jangan Lupa Memberikan Komentar, Namun Tolong Agar Menggunakan Bahasa Yang BAIK dan SOPAN Terima Kasih...