Help Delphi 3 new component.

Hi,

As i needed a data oriented TDateTimePicker (missing in Delphi 3), i decided
to write it myself.
But there is a slight problem: the table is not updated.
I use the message CN_COMMAND and the NotifyCode value CBN_EDITCHANGE to
detect a change and then set DataLink.Modified, but i found out that the
message was not used !?(my procedure TDBDateTimePicker.CNCommand(var
Message:TWMCommand), is never called.
The only way i got it to work, was to set FDataLink.Modified in CMExit it
works, but then the table is being updated even if the data has not changed
!
How do i detect a change in the DateTimePicker combobox ? See the code
below.

Thanks for the hint,
Regards,
Jmh.

TDBDateTimePicker code
-------------------------------------

unit XDBDateTimePicker;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, DB, DBCtrls, DsgnIntf;

type
  EDBDateTimePicker  = Class(Exception);

  TDBDateTimePicker = class(TDateTimePicker)
  private
    FDataLink :TFieldDataLink;
    FReadOnly :Boolean;
    Procedure SetDataSource(Value:TDataSource);
    Function  GetDataSource:TDataSource;
    Procedure SetDataField(Value:String);
    Function  GetDataField:String;
    Procedure DataChange(Sender:TObject);
    Procedure UpdateData(Sender:TObject);
    Procedure CNCommand(var Message:TWMCommand);Message CN_COMMAND;
    Procedure CMExit(var Message:TCMExit);Message CM_EXIT;
  protected
  public
    Constructor Create(AOwner:TComponent);Override;
    Destructor  Destroy;Override;
    Procedure   Loaded;Override;
  published
    Property DataSource:TDataSource Read GetDataSource Write SetDataSource;
    Property DataField :String      Read GetDataField  Write SetDataField;
    Property ReadOnly  :Boolean     Read FReadOnly     Write FReadOnly
Default False;
  end;

procedure Register;

implementation

Constructor TDBDateTimePicker.Create(AOwner:TComponent);
begin
Inherited Create(AOwner);
FDatalink:=TFieldDataLink.Create;
FDataLink.OnDataChange:=DataChange;
FDataLink.OnUpdateData:=UpdateData;
FReadOnly:=False;
end;

Destructor TDBDateTimePicker.Destroy;
begin
FDataLink.OnDataChange:=Nil;
FDataLink.OnUpdateData:=Nil;
FDataLink.Free;
FDataLink:=Nil;
Inherited Destroy;
end;

Procedure TDBDateTimePicker.Loaded;
begin
Inherited Loaded;
end;

Procedure TDBDateTimePicker.SetDataSource(Value:TDataSource);
begin
FDataLink.DataSource:=Value;
end;

Function TDBDateTimePicker.GetDataSource:TDataSource;
begin
Result:=FDataLink.DataSource;
end;

Procedure TDBDateTimePicker.SetDataField(Value:String);
begin
FDataLink.FieldName:=Value;
end;

Function TDBDateTimePicker.GetDataField:String;
begin
Result:=FDataLink.FieldName;
end;

Procedure TDBDateTimePicker.DataChange(Sender:TObject);
begin
if(FDataLink.Field <> Nil)then
  begin
  case Kind of
    dtkDate:Date:=FDataLink.Field.AsDateTime;
    dtkTime:Time:=FDataLink.Field.AsDateTime;
  end;
  end;
end;

Procedure TDBDateTimePicker.UpdateData(Sender: TObject);
begin
if(FDataLink.Field <> Nil)and(FReadOnly = False)then
  begin
  case Kind of
    dtkDate:FDataLink.Field.AsDateTime:=Date;
    dtkTime:FDataLink.Field.AsDateTime:=Time;
  end;
  end;
end;

Procedure TDBDateTimePicker.CNCommand(var Message:TWMCommand);
begin
if(Message.NotifyCode = CBN_EDITCHANGE)then
  begin
  if(FDataLink <> Nil)then FDataLink.Modified;
  end;
Inherited;
end;

procedure TDBDateTimePicker.CMExit(var Message:TCMExit);
begin
try
  if(FDataLink <> Nil)then FDataLink.UpdateRecord;
except
  On Exception do SetFocus;
end;
Inherited;
end;

procedure Register;
begin
RegisterComponents('XDBControls', [TDBDateTimePicker]);
end;

end.