We don't display ads so we rely on your Bitcoin donations to 1KWEk9QaiJb2NwP5YFmR24LyUBa4JyuKqZ
Post date: Mar 12, 2010 1:58:52 AM
This snippet shows you how to modify the default delphi components to suit your needs. This example allows the user to specify an alignment for the text in the edit box.
unit mnEdit;interfaceuses SysUtils, Classes, Controls, StdCtrls, Windows;type type TmnEdit = class(TEdit) private FAlignment: TAlignment; procedure SetAlignment(Value: TAlignment); protected procedure CreateParams(var Params: TCreateParams); override; public property Alignment: TAlignment read FAlignment write SetAlignment; end;procedure Register;implementationprocedure Register; procedure Register;begin RegisterComponents('mnEdit', [TmnEdit]); RegisterComponents ( 'mnEdit', [TmnEdit]);end;{ TmnEdit }procedure TmnEdit.CreateParams(var Params: TCreateParams);const Alignments : array[TAlignment] of LongWord= (ES_Left,ES_Right, ES_Center);begin inherited CreateParams(Params); Params.Style := Params.Style or Alignments[FAlignment];end;procedure TmnEdit.SetAlignment(Value: TAlignment);begin if FAlignment <> Value then begin FAlignment := Value; RecreateWnd; end;end;end.