Pessoal eu tenho esse componente abaixo que criei do TDateEdit do RxLib, só para implementar a cor, agora estava querendo
implementar no Evento onExit dele o preenchimento de data Automatica....atualmente eu faço assim no OnExit no componente quando está no form:
procedure TFrmConsultaVenda.TxtDtIniExit(Sender: TObject);
var
CarDt : Integer;
Data : String;
begin
if TxtDtIni.Text <> ' / / ' then
begin
Data := Trim(TiraMascara(TxtDtIni.Text));
CarDt := Length(Data);
if Length(Trim(TiraMascara(TxtDtIni.Text))) = 2 then
begin
Data := Data + FormatDateTime('/mm/yyyy',Date);
TxtDtIni.Text := Data;
end
else
if Length(Trim(TiraMascara(TxtDtIni.Text))) = 4 then
begin
Data := Data + FormatDateTime('/yyyy',Date);
TxtDtIni.Text := Data;
end;
end;
end;
Abaixo o componente que criei.
unit Data;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Mask, ToolEdit, Graphics, Messages;
type
TData = class(TDateEdit)
private
OnEnterColor: TColor;
OnExitColor: TColor;
procedure ExportaColor(const Value: TColor);
procedure ImportaColor(const Value: TColor);
protected
procedure ColocaCor(Sender: TObject);
procedure RetiraCor(Sender: TObject);
procedure ImportaCor(Value: TColor);
procedure ExportaCor(Value: TColor);
public
constructor Create(Aowner: TComponent); override;
procedure CMEnter(var Msg: TMessage); message CM_ENTER;
procedure CMExit(var Msg: TMessage); message CM_EXIT;
published
property CorOnEnter: TColor read OnEnterColor write ImportaColor;
property CorOnExit: TColor read OnExitColor write ExportaColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('CompsProprios', [TData]);
end;
{ TData }
procedure TData.CMEnter(var Msg: TMessage);
begin
ColocaCor(Self);
inherited
end;
procedure TData.CMExit(var Msg: TMessage);
begin
RetiraCor(Self);
inherited
end;
procedure TData.ColocaCor(Sender: TObject);
begin
if Sender is TDateEdit then
TDateEdit(Sender).Color := OnEnterColor;
end;
constructor TData.Create(Aowner: TComponent);
begin
inherited;
OnEnterColor := clSkyBlue;
OnExitColor := clWindow;
OnEnter := ColocaCor;
OnExit := RetiraCor;
end;
procedure TData.ExportaColor(const Value: TColor);
begin
end;
procedure TData.ExportaCor(Value: TColor);
begin
OnExitColor := Value;
end;
procedure TData.ImportaColor(const Value: TColor);
begin
end;
procedure TData.ImportaCor(Value: TColor);
begin
OnEnterColor := Value;
end;
procedure TData.RetiraCor(Sender: TObject);
begin
if Sender is TDateEdit then
TDateEdit(Sender).Color := OnExitColor;
end;
end.
Question
robinhocne
Pessoal eu tenho esse componente abaixo que criei do TDateEdit do RxLib, só para implementar a cor, agora estava querendo
implementar no Evento onExit dele o preenchimento de data Automatica....atualmente eu faço assim no OnExit no componente quando está no form:
Abaixo o componente que criei. Edited by robinhocneLink to comment
Share on other sites
9 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.