folgenden Source in als maskeditL.pas speichern und in ein
package einbinden. Anschließend hast du eine neue Komponente namens TAlignEdit (und TAlignDBEdit). Eventeull das TAlignDBEdit rausnehmen wenn du kein
DB-zeugs bei deiner Delphiverision hast damits geht.
Delphi-Quellcode:
unit maskeditL;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, DBCtrls;
type
TAlignEdit =
class(TEdit)
private
{ Private-Deklarationen }
fAlignment : TAlignment;
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
procedure SetAlignment(
const Value: TAlignment);
procedure CreateParams(
var Params: TCreateParams);
override;
published
{ Published-Deklarationen }
property Alignment : TAlignment
read fAlignment
write SetAlignment;
end;
TAlignDBEdit =
class(TDBEdit)
private
{ Private-Deklarationen }
fAlignment : TAlignment;
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
procedure SetAlignment(
const Value: TAlignment);
procedure CreateParams(
var Params: TCreateParams);
override;
published
{ Published-Deklarationen }
property Alignment : TAlignment
read fAlignment
write SetAlignment;
end;
procedure Register;
implementation
procedure TAlignEdit.SetAlignment(
const Value: TAlignment);
begin
if Value <> fAlignment
then
begin
fAlignment := Value;
RecreateWnd;
// erzeuge Fenster neu -> CreateParams
end;
end;
procedure TAlignEdit.CreateParams(
var Params: TCreateParams);
const
cAlignStyles:
array [TAlignment]
of Cardinal = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited;
with Params
do
Style := Style
or cAlignStyles[fAlignment];
//taRightJustify];
end;
procedure TAlignDBEdit.SetAlignment(
const Value: TAlignment);
begin
if Value <> fAlignment
then
begin
fAlignment := Value;
RecreateWnd;
// erzeuge Fenster neu -> CreateParams
end;
end;
procedure TAlignDBEdit.CreateParams(
var Params: TCreateParams);
const
cAlignStyles:
array [TAlignment]
of Cardinal = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited;
with Params
do
Style := Style
or cAlignStyles[fAlignment];
//taRightJustify];
end;
procedure Register;
begin
RegisterComponents('
ESFEB', [TAlignEdit,TAlignDBEdit]);
end;
end.