I have solved the main problem.
By setting a private oncanfocusEvent, the first child (FDayEdit) is selected. Then i overwrite DialogKey, when one of my childs is focused, the main component gets focus (note that this triggers the oncanfocusevent). then default behaviour is called with inherrited.
thnx slomoto for showing me in the right direction.
PS: FindEdits assigns the Edits from the styleresource,and returns false if failed.
This is the oncanfocusEvent:
procedure TPWCalendar.FocusEdit(Sender: TObject; var ACanFocus: Boolean);
begin
if findedits and ( fDayEdit.IsFocused or FMonthEdit.IsFocused or FYearEdit.IsFocused)
then aCanFocus:=true
else begin
ACanFocus:=false;
if Findedits then
FDayEdit.SetFocus;
end;
end;
Then This is the DialogKey Event
procedure TPWCalendar.DialogKey(var Key: Word; Shift: TShiftState);
begin
if key=vktab then
if ischildfocused then begin
self.SetFocus;
inherited;
end;
end;